
var sortWord = ['price','change','supply','volume','marketcap'];
// var ajaxUrl = "http://10.232.162.71:8181/v1/";
// var ajaxUrl = 'http://25.0.90.120:8080/v1/';
var ajaxUrl = "http://front.blocknews.site:9001/v1/";
var rate = 6.8147; //汇率
var isUpdate = true;  //利好利空可更新标志

var mobile = "";

var sw = true;  //加载开关变量


// LIST
var transPlace = ['场内交易','场外交易'];  //交易场所
var transCode = ['买入','卖出']; //交易类型
var priceType = ['人民币','美元']; //币种标志
var infoType =['快讯','微博','twitter','精选资讯','技术分析',]; //tab类型
var opType = ['注册' ,'推荐', '登录','竞猜','分享']; //积分类型
var sourceType = {
    "01": "金色财经",  // "金色财经"
    "02": "头条",// 头条
    "03": "微信", // 微信
    "04": "知乎",  // 知乎
    "05": "微博",  // 微博
    "06": "twitter", // twitter
    "07": "币智慧",  // 币智慧
    "08": "aicoin",  // aicoin
    "09": "blockcc",  //blockcc
    "10": "巴比特"  ///巴比特
};

//深度复制对象
function oClone(obj){
    var objClone;
    if (obj.constructor == Object){
        objClone = new obj.constructor();
    }else{
        objClone = new obj.constructor(obj.valueOf());
    }
    for(var key in obj){
        if ( objClone[key] != obj[key] ){
            if ( typeof(obj[key]) == 'object' ){
                objClone[key] = oClone(obj[key]);
            }else{
                objClone[key] = obj[key];
            }
        }
    }
    objClone.toString = obj.toString;
    objClone.valueOf = obj.valueOf;
    return objClone;
}


$(function(){

    getRate(); //计算汇率

    //是否加载微博的大图功能
    if(document.getElementById('largeImgModal')){
        $(window).resize(function(){
            getBtnPosition();
        });
    }
    //消息提醒
    if(document.getElementById('warnMsg')){
        var left = ($(window).width()- 342)/2;
        var top = ($(window).height()- 60)/2;
        $('#warnMsg').css({top: top, left: left,opacity:0.5055});
        $('#warnMsg').fadeOut(0);
    }

    //定义VUE组件
    Vue.component('header-content',{
        data: function(){
            var currWeb = getUrlParams().web?getUrlParams().web:10;
            return {
                index:{name:'首页',url:"index.html"},
                information:{name:"资讯",url:"information.html"},
                currency:{name:"币种",url:"currency.html"},
                login:{name:"登录"},
                register:{name:"注册"},

                currWeb:currWeb,
                loginStatus: true,  //登录状态

                searchContent: "", //搜索内容
            };
        },
        props:['isOne','isTwo','isThree'],
        methods:{
            toLogin: function(){
                // alert('登录页面');
                location.href ="login.html";
            },
            toRegister:function(){
                // alert('注册页面');
                location.href ="register.html";
            },
            //
            toSearch: function(event){
                if(event.currentTarget.type == 'text'){
                    var str =  event.currentTarget.value;
                }else{
                    var str = $(event.currentTarget).prev().val();
                }
                if(str =='' || str == null || str == undefined){
                    $('.search-input').focus();
                }else{
                    // alert('开始搜索...'+str);
                    window.open('search.html?content='+encodeURI(encodeURI(str))+'&searchType=all');
                    // location.href = 'search.html?content='+str;
                }

            },
            //清除输入框内容
            clearInput:function(){
                this.searchContent = "";
            },
            toFocus:function(){
                // $('#header .clear-input').removeClass('hidden');
            },
            //高亮显示清除按钮
            highShow: function(event){
                event.currentTarget.style.color = "#999";
            },
            //高亮显示清除按钮
            remHighShow: function(event){
                event.currentTarget.style.color = "#ccc";
            },
            toPersonal:function(){
                location.href = 'personal.html';
            },
            toIndex:function(){
                location.href = "index.html";
            },
            toQuit:function(){
                //清理cookie
                this.loginStatus = false;
                safeQuit();
                // location.reload();

            }
        },
        mounted:function(){
            this.$nextTick(function(){

            });

            //当前页下面border显示
            $('#header .navbar-right li').eq(this.currWeb-1).addClass('nav-active');

            //检测当前用户是否登录
            if(isLogin()){
                this.loginStatus = true;
            }else{
                this.loginStatus = false;
            }
        },
        watch:{
            searchContent:function(nVal, oVal){
                console.log(nVal+'  ---  '+oVal);
                if(!nVal){
                    $('#header .clear-input').addClass('hidden');
                }else{
                    $('#header .clear-input').removeClass('hidden');
                }
            }
        },
        template:'<div class="content">\n' +
            '        <nav class="navbar">\n' +
            '            <div class="">\n' +
            '                <!-- Brand and toggle get grouped for better mobile display -->\n' +
            '                <div class="navbar-header">\n' +
            '                    <button type="button" class="navbar-toggle collapsed header-collapse" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" >\n' +
            // '                        <span class="sr-only">Toggle navigation</span>\n' +
            '                        <span class="icon-bar"></span>\n' +
            '                        <span class="icon-bar"></span>\n' +
            '                        <span class="icon-bar"></span>\n' +
            '                    </button>\n' +
            '                    <a class="navbar-brand" href="#"><img src="image/logo.png" style="display:inline-block;" @click="toIndex"></a>\n' +
            '                </div>\n' +
            '                <!-- Collect the nav links, forms, and other content for toggling -->\n' +
            '                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">\n' +
            '                    <ul class="nav navbar-nav navbar-right">\n' +
            '                        <li :class="{\'nav-active\': isOne}"><a :href="index.url"  >{{ index.name }}<span class="sr-only">(current)</span></a></li>\n' +
            '                        <li :class="{\'nav-active\': isTwo}"><a :href="information.url">{{ information.name }}</a></li>\n' +
            '                        <li :class="{\'nav-active\': isThree}"><a :href="currency.url"  v-cloak>{{ currency.name }}</a></li>\n' +
            '                        <li style="padding-left:24px;padding-right:40px;" class="hidden-xs  hidden-sm" v-cloak>\n' +
            '                            <input type="text" class="search-input"  placeholder="请输入搜索内容" @keyup.enter="toSearch">\n' +
            '                            <div style="" class="search-btn-group">\n' +
            '                                <span class="glyphicon glyphicon-remove hidden clear-input" style="" @click="clearInput" @mouseEnter="highShow" @mouseLeave="remHighShow"></span>\n' +
            '                                <img src="image/sousuo.png" class="search-btn" style="" @click="toSearch" >\n' +
            '                            </div>\n' +
            '                            <!--<img src="image/sousuo.png" style="margin-left:-30px;margin-top:-4px;" @click="toSearch" >-->\n' +
            '                        </li>\n' +
            '                        <template v-if="loginStatus"  v-cloak>\n' +
            '                            <li class="personal" style="padding-right:4px;"><img src="image/header.png" @click.prevent="toPersonal" /></li>\n' +
            '                            <li class="personal" style="padding-right:0"><a href="###" @click.prevent="toPersonal">个人中心</a></li>\n' +
            '                            <li class="vline"><div></div></li>\n' +
            '                            <li claas="personal" ><a href="###" @click.prevent="toQuit">退出</a></li>\n' +
            '                        </template>\n' +
            '                        <template v-else  v-cloak>\n' +
            '                            <li style="padding-right:4px;" class="hidden-xs  hidden-sm"><img src="image/header.png" alt="" @click.prevent="toPersonal" /></li>\n' +
            '                            <li class="login" style="padding-right:0;"><a href="###" @click.prevent="toLogin">登录</a></li>\n' +
            '                            <li class="vline hidden-xs hidden-sm"><div style=""></div></li>\n' +
            '                            <li class="register" style="padding-left:0;padding-right:0;">\n' +
            '                                <a href="###" @click.prevent="toRegister">注册</a>\n' +
            '                            </li>\n' +
            '                        </template>\n' +
            '                    </ul>\n' +
            '                </div><!-- /.navbar-collapse -->\n' +
            '            </div><!-- /.container-fluid -->\n' +
            '        </nav>\n' +
            '    </div>',
    });


    //头部的VUE设置
    var header = new Vue({
        el: '#header',
    });



    Vue.component('footer-content',{
        data:function(){
            return {};
        },
        methods:{
            goFeedback: function(){
                window.open('feedback.html');
            }
        },
        template:'<div class="content">\n' +
            '        <div class="left">\n' +
            '            <img src="image/footer-logo.png"><p class="title">出品</p>\n' +
            '            <p class="copy">©2018 区块头条网 京ICP备110123456号</p>\n' +
            '        </div>\n' +
            '        <div class="right">\n' +
            '            <img src="image/message.png">\n' +
            '            <span @click="goFeedback" class="pointer">意见反馈</span>\n' +
            '        </div>\n' +
            '    </div>',
    });

    //底部设置
    var foot = new Vue({
        el:"#footer",
    });



    //隐藏共享框
    $('#main').on('mouseleave','.share-type',function(){
        closeShare();
    });

    //为每一页增加回到顶部按钮
    var toTop = document.createElement('img');
    toTop.setAttribute('src','image/toTop.png');
    toTop.setAttribute('id','to-top');
    toTop.setAttribute('class','hidden');
    document.getElementById('footer').appendChild(toTop);

    $('#to-top').hover(function(){
        $(this).attr('src','image/toTop2.png');
    },function(){
        $(this).attr('src','image/toTop.png');
    });

    $('#to-top').click(function(){
        $('html,body').animate({scrollTop: 0}, 500);
    });

    addLoad(function(){
        if(getScrollTop() > 500){
            // var right = parseInt($('#main .content').css('marginRight'))- 60;
            // $('#to-top').removeClass('hidden').css('right',right);
            $('#to-top').removeClass('hidden');
        }
        if(getScrollTop() <= 500){
            $('#to-top').addClass('hidden');
        }
    });

});



//添加监听事件
function addLoad(fn){
    // 注册scroll事件并监听
    if(window.addEventListener){
        window.addEventListener('scroll',fn,false);
    }else if(window.attachEvent){
        window.attachEvent("onscroll", fn);
    }
}
//取消监听事件
function cancelLoad(arr){ //取消事件函数数组
    for(var i=0; i<arr.length; i++){
        if (window.removeEventListener) {                   // // 所有浏览器，除了 IE 8 及更早IE版本
            window.removeEventListener("scroll", arr[i],false);
        } else if (window.detachEvent) {                   // IE 8 及更早IE版本
            window.detachEvent("onscroll", arr[i]);
        }
    }
}

//得到滚动条高度
function getScrollTop() {
   var scrollTop =  window.pageYOffset  //用于FF
    || document.documentElement.scrollTop
    || document.body.scrollTop
    || 0;
   return parseFloat(scrollTop);
}


// 设置一个开关来避免重负请求数据
// var sw = true;
// function scroLoad(name){
//     // 判断是否滚动到底部
//     if(document.body.scrollTop + window.innerHeight >= document.body.offsetHeight -100) {
//         // 如果开关打开则加载数据
//         if(sw==true){
//             // 将开关关闭
//             sw = false;
//             $('.loadData').removeClass('hidden');
//             setTimeout(function(){
//                 name();
//             },1000);
//         }
//     }
// }
//增加日历标记
function addCalenderMark(list,myCalender){
    if(list instanceof  Object){
        for(var time in list){
            myCalender.addMark(time,list[time]);
        }
    }
}
//判断闰年
function getRunNian(year){
    if(year%400 ===0 ||(year%4===0 && year%100 !== 0)){
        return true;
    }else{
        return false;
    }
}

//高亮显示色
function setHighLight(content,keyword){
    if (content && content.length > 0) {
        // 匹配关键字正则
        var  replaceReg = new RegExp(keyword, 'g');
        // 高亮替换v-html值
        var replaceString = '<span class="search-high-color">' + keyword+ '</span>';
        // 开始替换
        content  = content.replace(replaceReg, replaceString);
        return content;
    }
}

//判断用户是否登录
function isLogin(){
    if($.cookie('loginNo') && $.cookie('token') && $.cookie('userId') ){
        return true;
    }
    return false;
}

//快讯加载数据
function quickLoadData(){
    var sw = true;
    if(getScrollTop() + window.innerHeight >= document.body.offsetHeight-50) {
        //统计快讯已有条数
        var count = 0;
        for(var key in this.quickBlock){
            count += this.quickBlock[key].length;
        }
        //判断是否继续加载
        if(this.totalNum > count  ){
            $('.loadData').removeClass('hidden');
            if(sw==true){
                sw = false;
                //获取动态资讯
                this.currPage++;
                var data = {
                    infoType:'1' ,
                    pageSize:this.pageSize,
                    pageNum:this.currPage,
                    keyword:this.keyword,
                    element: this,
                };
                if(this.keys){ data.keys = this.keys ;}
                //判断是否为全局搜索
                var args = getUrlParams();
                if(args.searchType  && args.searchType == 'all'){
                    getSearchList(data);
                }else{
                    getQuikeList(data);
                }
            }
        }
    }
}

//精选资讯加载数据
function siftLoadData(){
    if(getScrollTop() + window.innerHeight >= document.body.offsetHeight-50) {
        console.log(this.totalNum +'----'+ this.siftBlock.length);
        if (this.totalNum > this.siftBlock.length) {
            $('.loadData').removeClass('hidden');
            if (sw == true) {
                sw = false;
                this.currPage++;
                var data = {
                    infoType: '4', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                    keyword: this.keyword, //关键字	否	100	String	查询关键字
                    pageSize: this.pageSize, //	每页条数	否	9	Number	默认10，最大50
                    pageNum: this.currPage, //第几页	否	9	Number	默认1
                    element: this,
                };
                if(this.keys){ data.keys = this.keys ;}
                //判断是否为全局搜索
                var args = getUrlParams();
                if (args.searchType && args.searchType == 'all') {
                    getSearchList(data);
                } else {
                    getArticlesList(data)
                }
            }
        }
    }
}

//twitter加载数据
function twitterLoadData(){
    // var sw = true;
    if(getScrollTop() + window.innerHeight >= document.body.offsetHeight-50) {
        if(this.totalNum > this.twitterBlock.length) {
            $('.loadData').removeClass('hidden');
            if (sw == true) {

                sw = false;
                //获取动态资讯
                this.currPage++;
                var data = {
                    infoType: '3', //	资讯类型	是	2	Number	2 微博 3 twitter
                    keyword: this.keyword, //关键字	否	100	String	查询关键字
                    pageSize: this.pageSize, //	每页条数	否	9	Number	默认10，最大50
                    pageNum: this.currPage, //第几页	否	9	Number	默认1
                    element: this,
                };
                if(this.keys){ data.keys = this.keys ;}
                //判断是否为全局搜索
                var args = getUrlParams();
                if (args.searchType && args.searchType == 'all') {
                    getSearchList(data);
                } else {
                    getDynamicList(data);
                }
            }
        }
    }
}

//微博加载数据
function blogLoadData(){
    // var sw = true;
    if(getScrollTop() + window.innerHeight >= document.body.offsetHeight-50) {
        console.log(this.totalNum +'----'+ this.blogBlock.length);
        if(this.totalNum > this.blogBlock.length) {
            $('.loadData').removeClass('hidden');
            if (sw == true) {
                sw = false;
                //获取动态资讯
                this.currPage++;
                var data = {
                    infoType: '2', //	资讯类型	是	2	Number	2 微博 3 twitter
                    keyword: this.keyword, //关键字	否	100	String	查询关键字
                    pageSize: this.pageSize, //	每页条数	否	9	Number	默认10，最大50
                    pageNum: this.currPage, //第几页	否	9	Number	默认1
                    element: this,
                };
                if(this.keys){ data.keys = this.keys ;}
                //判断是否为全局搜索
                var args = getUrlParams();
                if (args.searchType && args.searchType == 'all') {
                    getSearchList(data);
                } else {
                    getDynamicList(data);
                }
            }
        }
    }
}

//技术分析加载数据
function skillLoadData(){
    // var sw = true;
    if(getScrollTop() + window.innerHeight >= document.body.offsetHeight-50) {
        if(this.totalNum > this.skillBlock.length) {
            $('.loadData').removeClass('hidden');
            if (sw == true) {
                this.currPage++;
                var data = {
                    infoType: '5', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                    keyword: this.keyword, //关键字	否	100	String	查询关键字
                    pageSize: this.pageSize, //	每页条数	否	9	Number	默认10，最大50
                    pageNum: this.currPage, //第几页	否	9	Number	默认1
                    element: this,
                };
                //判断是否为全局搜索
                if(this.keys){ data.keys = this.keys ;}
                var args = getUrlParams();
                if (args.searchType && args.searchType == 'all') {
                    getSearchList(data);
                } else {
                    getArticlesList(data);
                }
            }
        }
    }
}


//根据类型选择分享方式
function shareType(type,event){
    var infoType =  $(event.currentTarget).parent().next().attr('infotype');
    var id = event.currentTarget.getAttribute('value');
    var title =  $(event.currentTarget).parent().parent().parent().find('.title').text() ? $(event.currentTarget).parent().parent().parent().find('.title').text() : '区块头条';
    var path = location.pathname.split('/');
    path = path.splice(1,path.length-2);
    if(path.length >= 2){
        path = path.join('/');
        path = path+'/';
    }else if(path.length == 1){
        path = path[0]+'/';
    }else{
        path = "";
    }
    var picurl = "";
    var url = "";
    switch(parseInt(infoType)){
        case 1:
            url = location.protocol+'//'+location.host+'/'+path+'quickText.html?id='+id+'&type='+infoType;
            break;
        case 2:
            url = location.protocol+'//'+location.host+'/'+path+'blogText.html?id='+id+'&type='+infoType;
            break;
        case 3:
            url = location.protocol+'//'+location.host+'/'+path+'twitterText.html?id='+id+'&type='+infoType;
            break;
        case 4:
        case 5:
            url = location.protocol+'//'+location.host+'/'+path+'newsText.html?id='+id+'&type='+infoType;
            break;
        case 6:
            url = location.protocol+'//'+location.host+'/'+path+'index.html?r='+$.cookie('mobile');
            break;
        default:
    }
    switch (parseInt(type)) {
        case 0: //复制
                var str = '详情点击查看：'+url;
            // const btn = document.querySelector('#btn');
                const input = document.createElement('input');
                input.setAttribute('readonly', 'readonly');
                input.setAttribute('value', str);
                document.body.appendChild(input);
                // input.setSelectionRange(0, 9999);
                 input.select();
                if (document.execCommand('copy')) {
                    document.execCommand('copy');

                    //显示消息提醒
                    $('#warnMsg').fadeIn('slow');
                    setTimeout(function(){
                        $('#warnMsg').fadeOut('slow');
                    },2000);
                }
                document.body.removeChild(input);
            break;
        case 1: //新浪微博
            var sharesinastring='http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='+picurl;
            window.open(sharesinastring,'newwindow','height=400,width=400,top=100,left=100');
            break;
        case 2: //微信
            break;
        case 3: //QQ分享
            var shareqqzonestring='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary='+title+'&pics='+picurl+'&title='+title+'&url='+encodeURIComponent(url);
            window.open(shareqqzonestring,'newwindow','height=400,width=400,top=100,left=100');
            break;
    }

    closeShare();
}
//共享框显示
function showShare(event){
    var id = event.currentTarget.getAttribute('value');
    var infoType = event.currentTarget.getAttribute('infotype');
    var path = location.pathname.split('/');
    path = path.splice(1,path.length-2);
    if(path.length >= 2){
        path = path.join('/');
        path = path+'/';
    }else if(path.length == 1){
        path = path[0]+'/';
    }else{
        path = "";
    }
    var left = 70;
    var top = 330;
    switch(parseInt(infoType)){
        case 1:
            var url = location.protocol+'//'+location.host+'/'+path+'quickText.html?id='+id+'&type='+infoType;
            break;
        case 2:
            var url = location.protocol+'//'+location.host+'/'+path+'blogText.html?id='+id+'&type='+infoType;
            break;
        case 3:
            var url = location.protocol+'//'+location.host+'/'+path+'twitterText.html?id='+id+'&type='+infoType;
            break;
        case 4:
        case 5:
            var url = location.protocol+'//'+location.host+'/'+path+'newsText.html?id='+id+'&type='+infoType;
            break;
        case 6:
            top = -30;
            left = 100;
            var url = location.protocol+'//'+location.host+'/'+path+'index.html?r='+$.cookie('mobile');
            break;
        default:
    }
    if($(event.currentTarget).prev().hasClass('hidden')){
        $('.share-type').css({
            left: event.x - left,
            top: event.y - top,
        });
        $('.share-type').addClass('hidden');
        $(event.currentTarget).prev().find('.code').html("");
        $(event.currentTarget).prev().find('.code').qrcode({
            // render    : "table",                <!--二维码生成方式 -->
            text    : url, <!-- 二维码内容  -->
            width : "110",               //二维码的宽度
            height : "110",
        });
        $(event.currentTarget).prev().removeClass('hidden');

    }else{
        $(event.currentTarget).prev().addClass('hidden');
    }
}
//关闭共享框
function closeShare() {
    $('.share-type').addClass('hidden');
}


//显示大图
function showLargeImg(index,imgIndex,event){
    //index消息序号    imgIndex 图片序号，  event对象
    // console.log(this.blogBlock[index].largeUrls[imgIndex]);
    this.largeImg.imgUrl = "";
    if(index == 'no'){
        if(this.largeUrls.length == 1){
            $('#largeImgModal .left-btn').addClass('hidden');
            $('#largeImgModal .right-btn').addClass('hidden');
        }else{
            $('#largeImgModal .left-btn').removeClass('hidden');
            $('#largeImgModal .right-btn').removeClass('hidden');
        }
    }else{
        if(this.blogBlock[index].largeUrls.length == 1){
            $('#largeImgModal .left-btn').addClass('hidden');
            $('#largeImgModal .right-btn').addClass('hidden');
        }else{
            $('#largeImgModal .left-btn').removeClass('hidden');
            $('#largeImgModal .right-btn').removeClass('hidden');
        }
    }

    var width = $(window).width();
    var height = $(window).height();
    $('#largeImgModal').modal('show').css({
        'margin-top':0,
        'margin-left':0,
        'width':width,
        'height':height,
    });
    //计算largeModal各个按钮的位置
    getBtnPosition();
    if(index == 'no'){
        this.largeImg.imgUrl = this.largeUrls[imgIndex];
        this.largeImg.index = index;
        this.largeImg.imgIndex = imgIndex;
    }else{
        this.largeImg.imgUrl = this.blogBlock[index].largeUrls[imgIndex];
        this.largeImg.index = index;
        this.largeImg.imgIndex = imgIndex;
    }
}

//定位大图显示时的按钮位置和滚动条
function getBtnPosition(){
    var width = 720;  //设定最大显示图片显示框
    var winWidth =  $(window).width();
    var winHeight = $(window).height();


    $('#largeImgModal').css({width:winWidth, height:winHeight});
    // $('#largeImgModal .modal').css({width:winWidth, height:winHeight});
    $('#largeImgModal .modal-dialog').css({width:winWidth -30, height:winHeight});
    $('#largeImgModal .modal-content').css({width:winWidth +30, height:winHeight});


    // console.log(winWidth);
    if(winWidth > width){
        var cWidth = (winWidth - width)/4;
        $('#largeImgModal .modal-body').css({width:width, height: winHeight * 0.9,left:(winWidth - width)/2,top:winHeight * 0.1/2});
        $('#largeImgModal .modal-body img').css({maxWidth:width});
    }else{
        var cWidth = 50;
        $('#largeImgModal .modal-body').css({width:winWidth-200, height: winHeight * 0.9,left:100,top:winHeight * 0.1/2});
        $('#largeImgModal .modal-body img').css({maxWidth:winWidth-200});
    }
    var cHeight = winHeight/2 - 25 ;
    $('#largeImgModal .left-btn').css({left:cWidth, top:cHeight});
    $('#largeImgModal .right-btn').css({right:cWidth, top:cHeight});
    $('#largeImgModal .close-btn').css({right:cWidth, top:100});
}

//缩略图
function getImgSize(img){
    //要求得到的尺寸  220 x 140
    var width = 220;
    var height = 140;
    var baseRate = width / height;
    var cWidth = Math.abs(img.width - width) ;
    var cHeight = Math.abs(img.height - height);
    var imgRate = img.width / img.height;

    if(cWidth/cHeight > baseRate ){
        img.height = height;
        img.width = height * imgRate;
    }else{
        img.width = width;
        img.height = width / imgRate;
    }
    var top = Math.abs(img.width -width) /2;
    var left = Math.abs(img.height -height) /2;
    return {width: img.width, height: img.height,top:0-top, left:0-left};
}

// 头像图像加载失败
function imgLoadError() {
    var img=event.srcElement;
    img.src="image/header.png";
    img.onerror=null; //控制不要一直跳动
}
// 币种图像加载失败
function imgLoadBlockError() {
    var img=event.srcElement;
    img.src="image/btc.png";
    img.onerror=null; //控制不要一直跳动
}

//根据当前点击页码跳转
function setCurrPage(currList){
    this[currList].currArea = []; //清空当前页码区
    //判断页码总数是否小于 页码最大值
    if(this[currList].totalNum <= this[currList].maxPage){
        for(var m=0; m<this[currList].totalNum; m++){
            Vue.set(this[currList].currArea,this[currList].currArea.length, m+1);
        }
        this.$nextTick(function(){
            $('.page-num-btn').removeClass('page-active');
            $('.page-num-btn').eq(this[currList].currPage-1).addClass('page-active');
        });

    }else{
        var min = parseInt(this[currList].currPage - Math.floor(this[currList].maxPage /2));
        var max = parseInt(this[currList].currPage + Math.floor(this[currList].maxPage /2));
        if( min >1 &&  max <= this[currList].totalNum ){
            for(var k=0; k< this[currList].maxPage; k++){
                Vue.set(this[currList].currArea,this[currList].currArea.length,min+k);
            }
            this.$nextTick(function(){
                $('.page-num-btn').removeClass('page-active').eq(Math.floor(this[currList].maxPage /2)).addClass('page-active');
            });

        }else{
            $('.page-next').removeClass('disabled');
            $('.page-num-btn').removeClass('page-active');
            //判断在前几页还是后几页
            if(min <=1 ){
                // this[currList].currArea = [];
                for(var m=0; m<this[currList].maxPage; m++){
                    Vue.set(this[currList].currArea,this[currList].currArea.length, m+1);
                }
                this.$nextTick(function(){
                    $('.page-num-btn').eq(parseInt(this[currList].currPage)-1).addClass('page-active');
                });

            }else{
                var startPage = this[currList].totalNum - this[currList].maxPage+1;
                for(var m=0;  m<this[currList].maxPage ; m++){
                    Vue.set(this[currList].currArea,this[currList].currArea.length, startPage++);
                }
                this.$nextTick(function(){
                    $('.page-num-btn').eq(this[currList].maxPage-(this[currList].totalNum - this[currList].currPage)-1).addClass('page-active');
                });

            }
        }
    }
}

//向前或向后翻页
function toPage(currList,event){
    var page = event.currentTarget;
    var value = parseInt(page.value);  //点击的当前页码
    switch(value){
        case  -1:  //往前翻页
            if(this[currList].currPage - 1 > 0 ){
                this[currList].currPage--; //设置当前页码减 1

                $(page).prevUntil('.next-btn').removeClass('disabled');

                this.runCurrencyAPI();
            }else{
                $(page).addClass('disabled');  //设置禁用标志
            }
            break;
        case 0 :  //向后一页
            console.log((this[currList].currPage+1) + '---- '+ this[currList].totalNum);
            if(this[currList].currPage + 1 <= this[currList].totalNum ){
                this[currList].currPage++; //设置当前页码加 1
                // this.setCurrPage(currList);
                $(page).prevUntil('.prev-btn').removeClass('disabled');

                this.runCurrencyAPI();

            }else{
                $(page).addClass('disabled'); //设置禁用标志
            }
            break;
        default:
            this[currList].currPage = value; //设置当前页码
            this.runCurrencyAPI();
    }
}

//输入值跳转
function jumpPage(currList,event){
    var inPage = parseInt($('.page-jump').find('input').val());
    if(inPage >0 && inPage <= this[currList].totalNum ){
        this[currList].currPage  = inPage; //设置当前页码
        this.runCurrencyAPI();

    }else{
        $('.page-jump').find('input').focus();
    }
}
//每页显示条目数
function setPageNum(currList,event){
    this[currList].pageSize = event.currentTarget.value;
    this.runCurrencyAPI();

}
//表格按字段排序
function changeSort(event){
    // var currList = this.getCurrType()=='0' ? 'market': 'optional' ;  // 0 货币列表   1 自选
    var currList = "";
    switch(parseInt(this.getCurrType())){
        case 0:
            currList = 'market';
            break
        case 1:
            currList = 'optional';
            break;
        case 2:
            currList = 'bourseBlock';
            break;
    }

    var sortWord = event.currentTarget.getAttribute('type');  //按什么字段排序
    var sortType = event.currentTarget.getAttribute('value'); //降序1 升序 0

    this[currList].sortWord = sortWord;
    this[currList].pageNum = 1;
    if(sortType == '1'){
        //降序排列
        $('.sort-img').attr({value:1,src:'image/paixu1.png'});
        this[currList].sortType = 0;
        event.currentTarget.setAttribute('value','0');
        event.currentTarget.setAttribute('src','image/paixu2.png');
    }else{
        //升序排列
        $('.sort-img').attr({value:1,src:'image/paixu1.png'});
        this[currList].sortType = 1;
        event.currentTarget.setAttribute('value','1');
        event.currentTarget.setAttribute('src','image/paixu1.png');
    }
    this.runCurrencyAPI();
}

//个人中心 -  左边菜单隐藏和显示
function showLeftMenu(sign){
    if(sign){
        //个人信息
        $('.my-phone, .my-reg-time').removeClass('hidden');
        $('.my-status, .my-login').addClass('hidden');
    }else{
        $('.my-phone, .my-reg-time').addClass('hidden');
        $('.my-status, .my-login').removeClass('hidden');
    }
}


//判断中文字节和英文字节长度
function getStrLength(str){
    var len = 0;
    for(var i=0; i<str.length; i++){
        var c = str.charCodeAt(i);
        if((c>= 0x0001 && c<= 0x007e) || (0xff60 <=c && c<= 0xff9f)){
            len++;
        }else{
            len += 1;
        }
    }
    return len;
}


//千分位显示
//数字显示为千分位
function toThousands(num,bit){
    var  result='';
    var  arr =[];

    if(bit){
       num = parseFloat(num).toFixed(bit);
    }
    arr = num.toString().split('.');
    if(!arr[1]){
        result = '.00';  //小数部分
    }else{
        result = '.'+arr[1];  //小数部分
    }
    num = arr[0];    //整数部分
    while(num.length > 3){
        result = ','+num.slice(num.length-3,num.length)+result;
        num = num.slice(0,num.length-3);
    }

    result = num + result;
    return  result;
}

//将数字转换成千分位带2位小数
function setNumber(num){
    if(num == undefined || num == '' || num == 'null'){
        return '';
    }
    return toThousands(parseFloat(num).toFixed(2));
}

//换算成 中文  万，亿
function setBitNum(num,bit){
    num = parseFloat(num);
    if(num >= 0){
        var t = "";
    }else{
        var t = "-";
    }
    num = Math.abs(num);
    if(bit){
        if(num >= 100000000){
            return   t+ parseFloat((num /100000000).toFixed(bit))+'亿';
        }else if(num > 10000){
            return    t+ parseFloat((num /10000).toFixed(bit))+'万';
        }else {
            return   t+  parseFloat(num.toFixed(bit));
        }
    }else{
        if(num >= 100000000){
            return    t+  parseFloat(num /100000000).toFixed(2)+'亿';
        }else if(num > 10000){
            return   t+  parseFloat(num /10000).toFixed(2)+'万';
        }else if(num >=0 && num < 1){
            return   t+  parseFloat(num.toFixed(8));
        }else{
            return   t+  parseFloat(num.toFixed(2));
        }
    }
}
//涨幅率
function setChange(num,flag){
    var change = "";
    num = parseFloat(num)*100;
    if(flag){
        change = num.toFixed(2)+'%' ;  //涨幅
    }else{
        if(num){
            if(num < 0 ){
                change = num.toFixed(2)+'%' ;  //涨幅
            }else{
                change = '+' +  num.toFixed(2)+'%' ;  //涨幅
            }
        }
    }
    return change;

}

// 前导0补充
function addZero(str) {
    if(parseInt(str)<10){
        str = '0'+str;
    }
    return str;
}
//补充加减号
function addPlusMinus(num,isShowPlus){
    if(isShowPlus){
        if(num < 0){
            num = '-'+num;
        }
    }else{
        if(num >=0){
            num = '+'+num;
        }else{
            num = '-'+num;
        }
    }

    return num;
}

//交易对时间显示格式
function getTickersDate(time){
    var today = new Date;
    var tTime = today.getTime();

    var old = new Date(time);
    var oYear =  old.getFullYear();
    var oMonth = old.getMonth()+1;
    var oDate = old.getDate();

    var cTime =  tTime - time;
    if(cTime < 60 * 1000){
        return '刚刚';
    }
    for(var s= 1; s < 10; s++){
        if(cTime >= s * 60 * 1000 && cTime < (s+1)*60 * 1000){
            return  s+'分钟前';
        }
    }

    for(var m= 10; m < 60; m+=10){
        if(cTime >= m * 60 * 1000 && cTime < (m+10)*60 * 1000){
            return  m+'分钟前';
        }
    }

    for(var h= 1; h < 24; h++){
        if(cTime >= h * 60 * 60 * 1000 && cTime < (h+1)* 60 *60 * 1000){
            return  h+'小时前';
        }
    }

    return  oYear+'-'+addZero(oMonth)+'-'+addZero(oDate);
}

//时间戳判断
function getTimeType(time){
    var today = new Date;
    var tYear =  today.getFullYear();
    var tMonth = today.getMonth()+1;
    var tDate = today.getDate();

    var old = new Date(time);
    var oYear =  old.getFullYear();
    var oMonth = old.getMonth()+1;
    var oDate = old.getDate();

    if(tYear == oYear && tMonth == oMonth && tDate == oDate ){
        return {type:'today',time: addZero(old.getHours())+':'+addZero(old.getMinutes())};
    }else{
        return {type:oYear+'-'+addZero(oMonth)+'-'+addZero(oDate),time: addZero(old.getHours())+':'+addZero(old.getMinutes())};
    }
}

//时间差
function getTimeChar(oldTime){
    var date =  new Date();  //当前时间
    var today = new Date(date.getFullYear()+'-'+addZero(date.getMonth()+1)+'-'+addZero(date.getDate())+' 00:00:00:000'); //当天零点时间戳
    var t = oldTime - today.getTime();  //文章时间与当天零点时间戳的差
    var nt = date.getTime() - today.getTime();  //当前时间与当天零点的时间戳的差
    //如果小于零，说明是昨天及以前
    if(t < 0 ){
        var old = new Date(oldTime);
        return old.getFullYear()+'-'+addZero(old.getMonth()+1)+'-'+addZero(old.getDate())+'  '+addZero(old.getHours())+':'+addZero(old.getSeconds());
    }

    //一天内，且大于一小时的，显示时间
    if( nt - t > 3600000){
        var old = new Date(oldTime);
        return addZero(old.getHours())+':'+addZero(old.getSeconds());
    }

    //一小时内的，大于一分钟
    if( nt - t > 60000){
        return Math.floor((nt-t)/60000)+'分钟前';
    }
    //一分钟以内
    return Math.floor(nt - t)+'秒前';

}
//货币详情页的时间
function getTimeChar2(oldTime){
    var date =  new Date();
    var today = new Date(date.getFullYear()+'-'+addZero(date.getMonth()+1)+'-'+addZero(date.getDate())+' 00:00:00:000'); //当天零点时间戳
    // var currTime = date.getTime();
    // var t = currTime - oldTime;
    var t = oldTime - today.getTime();  //文章时间与当天零点时间戳的差
    var nt = date.getTime() - today.getTime();  //当前时间与当天零点的时间戳的差

    //大于一天的，显示日期和时间
    //如果小于零，说明是昨天及以前
    if(t < 0 ){
        var old = new Date(oldTime);
        return old.getFullYear()+'-'+addZero(old.getMonth()+1)+'-'+addZero(old.getDate())+'  '+addZero(old.getHours())+':'+addZero(old.getSeconds());
    }
    // if(t > 86400000){
    //     var old = new Date(oldTime);
    //     return old.getFullYear()+'-'+addZero(old.getMonth()+1)+'-'+addZero(old.getDate())+'  '+addZero(old.getHours())+':'+addZero(old.getSeconds());
    // }

    //一天内，且大于一小时的，显示时间
    if( nt - t > 3600000){
        var old = new Date(oldTime);
        return '今天  '+ addZero(old.getHours())+':'+addZero(old.getSeconds());
    }

    //一小时内的，大于一分钟
    if( nt - t > 60000){
        return '今天  '+ Math.floor((nt - t)/60000)+'分前';
    }
    //一分钟以内
    return '今天  '+ Math.floor(nt - t)+'秒前';

}
// 时间戳转换
function getFullDate(time){
    var date = new Date(time);

    return date.getFullYear()+'-'+addZero(date.getMonth()+1)+'-'+addZero(date.getDate());
}
// 时间戳转换
function getFullDateTime(time){
    if(time){
        var date = new Date(time);
        return date.getFullYear()+'-'+addZero(date.getMonth()+1)+'-'+addZero(date.getDate())+' '+date.getHours()+":"+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
    }else{
        return "";
    }

}
//折线图中的 自定义时间格式
function getDivDate(time){
    var date = new Date(time);
    var weekday = ["周日","周一","周二","周三","周四","周五","周六"];
    var month = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"];
    var result =  weekday[date.getDay()]+",  "+ month[date.getMonth()]+"  "+addZero(date.getDate())+",  "+date.getHours()+':'+addZero(date.getMinutes());
    return result;
}
// console.log(getFullDate(new Date()));

//手机号验证
function checkPhone(phone){
    var strReg =/^[1][3|4|5|7|8][0-9]{9}$/g;
    if(strReg.test(phone)){
        return true;
    }else{
       return false;
    }
}

//密码验证
function checkPass(password){
    var strReg =/^\w{6,12}$/g;
    if(strReg.test(password)){
        return true;
    }else{
        return false;
    }
}

//验证码验证
function checkCode(code){
    var strReg =/^\d{4,6}$/g;
    if(strReg.test(code)){
        return true;
    }else{
        return false;
    }
}

//登录超时
function timeOut(){
    // $.cookie('loginNo',"");//	用户名	String	30	是
    // $.cookie('token',""); //	TokenId	String	32	是	登陆后必填
    // $.cookie('userId',"");//	用户Id	String	20	是	登陆后必填
    $.cookie('loginNo',null,{expires:-1});
    $.cookie('userId',null,{expires:-1});
    $.cookie('token',null,{expires:-1});

    //刷新当前页面
    location.reload(true);
}



/***
 *
 * 接口
 *
 * */

//3.1	查询首页汇总信息
function getHomeSummary(obj){
    // 获取首页头部信息
    var url=ajaxUrl+'home/summary';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        // var temp = new Object();
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.total = (parseFloat(data.data.allMarketCap)/100000000).toFixed(2);  //总价值
                obj.element.totalDay =  data.data.totalVolume ? (parseFloat(data.data.totalVolume)/100000000).toFixed(2) : 0; //24H成交价
                obj.element.blockNum = data.data.coinCount ; //总币种数量
                obj.element.upCount  = data.data.upCount ;  //成交涨跌

                var temp = {};
                //指数列表
                obj.element.exponent =[];
                for(var i=0; i< data.data.indexList.length; i++){
                    temp.indexName = data.data.indexList[i].indexName;
                    temp.indexValue = data.data.indexList[i].indexValue;
                    Vue.set(obj.element.exponent,obj.element.exponent.length,temp);
                    temp = {};
                }
                obj.element.currName =  obj.element.exponent[0].indexName;
                obj.element.currValue = obj.element.exponent[0].indexValue;

                //货币信息列表
                for(var i=0; i< data.data.coinList.length; i++){
                    temp.symbol = data.data.coinList[i].symbol;
                    temp.title=data.data.coinList[i].symbol + (data.data.coinList[i].name? ' / '+data.data.coinList[i].name : "" );
                    temp.val=data.data.coinList[i].price.toFixed(2);
                    temp.msg=data.data.coinList[i].marketCapRate ? "市场占有 "+setChange(data.data.coinList[i].marketCapRate,true) : "暂无";
                    temp.id= data.data.coinList[i].id;
                    if(data.data.coinList[i].change){
                        if(data.data.coinList[i].change >=0 ){
                            // temp.sign='image/up.png';  //此标志为 数值后面的三角箭头的方向
                            temp.isUp = true;
                        }else{
                            // temp.sign='image/down.png';  //此标志为 数值后面的三角箭头的方向
                            temp.isUp = false;
                        }
                    }

                    Vue.set(obj.element.blockProfile,obj.element.blockProfile.length,temp);
                    temp = {};
                }
                break;
            case 20001:
                timeOut();
                break;
            default:
                break;
        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.2	查询风口概念列表
function getSummaryConcepts(obj){
    // 查询风口概念信息
    // var url=ajaxUrl+'coins/concepts?hasCoin=1';
    var url=ajaxUrl+'summary/concepts';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var temp = {};
                obj.element.totalNum = data.data.length;
                if($(window).width() <840 && data.data.length >1){
                    obj.element.isShow = true;
                }else{
                    obj.element.isShow = false;
                }
                for(var i=0; i< data.data.length; i++){
                    temp.id = data.data[i].id ;  //主题ID
                    temp.title = data.data[i].name ;  //主题名
                    temp.avgChange = setChange(data.data[i].avgChange);  //平均涨幅
                    temp.location = obj.element.getItemLocation(i+1); //location定位
                    if(data.data[i].avgChange > 0){
                        temp.fontColor = 'font-up';
                    }else{
                        temp.fontColor = 'font-down';
                    }
                    //获得主题下面的小币种
                    temp.block = new Array();
                    for(var j=0; j < data.data[i].coinList.length; j++){
                        temp.block[j] = new Object();
                        temp.block[j].name = data.data[i].coinList[j].symbol;
                        temp.block[j].num = data.data[i].coinList[j].change ? setChange(data.data[i].coinList[j].change) : '-';
                        if((j+1)%3 == 2){
                            temp.block[j].middle = 'c-item-line';
                        }else{
                            temp.block[j].middle = '';
                        }
                        if(data.data[i].coinList[j].change >= 0){
                            temp.block[j].fontColor = 'font-up';
                            // temp.block[j].num = '+'+temp.block[j].num+'%';
                        }else{
                            temp.block[j].fontColor = 'font-down';
                            // temp.block[j].num = '-'+temp.block[j].num+'%';
                        }
                    }
                    Vue.set(obj.element.tuyereBlock,obj.element.tuyereBlock.length,temp);
                    temp= {};
                }
                //重新设置框大小
                obj.element.$nextTick(function(){
                    obj.element.setTuyereWidth();
                    //左右箭头,滑动函数
                    // $('.next-btn').on('click',{sign:'next'},obj.element.blockSilder);
                    // $('.prev-btn').on('click',{sign:'prev'},obj.element.blockSilder);
                });
                break;
            case 20001:
                timeOut();
                break;
            default:
        }//end 查询风口概念
    }).catch(function(error){
        console.log(error);
    });
}

//3.3	查询首页模块列表
function getHomeModules(obj){
    // 查询首页模块信息
    var url=ajaxUrl+'home/modules';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code ){
            case 10000:
                var temp = {};
                obj.element.lists = [];
                for(var i=0; i< data.data.length; i++){
                    temp.displayName  = data.data[i].displayName ;  //名称
                    temp.desc  = data.data[i].desc ;  //简称
                    temp.block = new Array();
                    if(data.data[i].coinList.length >9){
                        maxListNum = 9;
                    }else{
                        maxListNum = data.data[i].coinList.length;
                    }
                    temp.totalNum = maxListNum;
                    if($(window).width() <840 && temp.totalNum >1){
                        temp.isShow = true;
                    }else{
                        temp.isShow = false;
                    }
                    var index = 0;
                    for(var j=0; j < maxListNum; j++){
                        if(data.data[i].coinList[j] && data.data[i].coinList[j].symbol){
                            temp.block[index] = new Object();
                            //{id:1,name:'BTC',imgSrc:'image/btc.png',usd:6710.10, cny:44883.80,num:'+2.21%',location:'left-item',boxColor:'color-up'}
                            temp.block[index].id = data.data[i].coinList[j].id;
                            temp.block[index].name = data.data[i].coinList[j].symbol ? data.data[i].coinList[j].symbol : "  ";
                            temp.block[index].imgSrc = data.data[i].coinList[j].imgUrl ?data.data[i].coinList[j].imgUrl : 'image/btc.png';
                            temp.block[index].usd =data.data[i].coinList[j].price? '$ '+(data.data[i].coinList[j].price).toFixed(3): '&nbsp;';
                            temp.block[index].cny =data.data[i].coinList[j].price? '￥ '+((data.data[i].coinList[j].price)*rate).toFixed(4): '&nbsp;'; //需要调用接口转换成RMB
                            temp.block[index].num = data.data[i].coinList[j].change ? setChange(data.data[i].coinList[j].change) : '';
                            temp.block[index].location = obj.element.getItemLocation(j+1);
                            if(data.data[i].coinList[j].change >= 0){
                                temp.block[index].boxColor = 'color-up';
                            }else{
                                temp.block[index].boxColor = 'color-down';
                            }
                            index++;
                        }
                    }
                    Vue.set(obj.element.lists,obj.element.lists.length,temp);
                    temp= {};
                    index = 0;
                }
                //重新设置框大小
                obj.element.$nextTick(function(){
                    obj.element.setOtherWidth();
                    //左右箭头,滑动函数
                    // $('.next-btn').on('click',{sign:'next'},obj.element.blockSilder);
                    // $('.prev-btn').on('click',{sign:'prev'},obj.element.blockSilder);
                });
                break;
            case 20001:
                timeOut();
                break;

        }//end 查询风口概念
    }).catch(function(error){
        console.log(error);
    });
}



//3.4	查询快讯列表（首页右侧快讯）
function getQuikeListIndex(obj){
    var url=ajaxUrl+'lives';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        pageSize: obj.pageSize , //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum , //	第几页	否	9	Number	默认1
        keyword: obj.keyword, //	关键字	否	100	String	不为空则表示为按照关键字或者按照币种查询
};
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var temp = {};
                if(data.data.recordList.length > 0 ){
                    $('.noData').addClass('hidden');
                    obj.element.totalNum = data.data.totalNum;  //总记录数
                    for(var i=0; i< data.data.recordList.length; i++){

                        var arr = data.data.recordList[i].content.split('】');
                        if(arr.length > 1){
                            temp.content = $.trim(arr[1]); //内容
                            arr = arr[0].split('【');
                            arr = arr[1].split('|');
                            if(arr.length <2){
                                arr = arr[0].split('丨');
                            }
                            temp.title = $.trim(arr[1]); //标题
                        }else{
                            temp.title =  temp.content = $.trim(arr[0]); //内容和标题
                        }

                        // temp.source = $.trim(arr[0]); //来源
                        temp.source = sourceType[data.data.recordList[i].sourceType];
                        temp.id = data.data.recordList[i].id; //快讯ID
                        temp.time = getTimeChar(data.data.recordList[i].createdAt);  //创建时间
                        temp.good = data.data.recordList[i].upCounts;  //利好
                        temp.bad = data.data.recordList[i].downCounts; //利空

                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';

                        // temp.block = data.data.recordList[i].coinList[0]; //货币
                        temp.userImg = data.data.recordList[i].imgUrl ? data.data.recordList[i].coinList[0] : 'image/header.png'; //用户头像
                        // temp.username = data.data.recordList[i].coinList[0]; //用户名
                        temp.blocks = [];
                        //币种列表

                        var s = 0; //如果change不存在不记录
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j].change){
                                temp.blocks[s] = {};
                                temp.blocks[s].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[s].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[s].change = data.data.recordList[i].coinList[j].change ? setChange(data.data.recordList[i].coinList[j].change ) : "";
                                temp.blocks[s].name = data.data.recordList[i].coinList[j].symbol +  temp.blocks[s].change;
                                temp.blocks[s].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                s++;
                            }
                        }
                        //高亮显示
                        if(obj.keyword != ""){
                            temp.title = setHighLight(temp.title, obj.keyword);
                            temp.content = setHighLight(temp.content, obj.keyword);
                        }

                        Vue.set(obj.element.quickBlock,obj.element.quickBlock.length,temp);
                        temp= {};
                    }
                    $('.loadData').addClass('hidden');
                }else{
                    obj.element.totalNum = 0;
                    sw = true;
                    $('.noData').removeClass('hidden');
                    console.log('没有查询到相关内容！');
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.4-2	查询快讯列表(资讯页等)
//obj = {token, userId, url ,infoType , pageSize, pageNum, keyword, element }
function getQuikeList(obj){
    var url=ajaxUrl+'lives';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        pageSize: obj.pageSize , //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum , //	第几页	否	9	Number	默认1
        keyword: obj.keyword, //	关键字	否	100	String	不为空则表示为按照关键字或者按照币种查询
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $('.noData').addClass('hidden');
                $('.loadData').removeClass('hidden');
                if(data.data.recordList.length > 0 ){
                    var temp = {};
                    obj.element.totalNum = data.data.totalNum;  //总记录数
                    for(var i=0; i< data.data.recordList.length; i++){

                        var arr = data.data.recordList[i].content.split('】');
                        if(arr.length > 1){
                            temp.content = $.trim(arr[1]); //内容
                            arr = arr[0].split('【');
                            arr = arr[1].split('|');
                            if(arr.length <2){
                                arr = arr[0].split('丨');
                            }
                            temp.title = $.trim(arr[1]); //标题
                        }else{
                            temp.title =  temp.content = $.trim(arr[0]); //内容和标题
                        }

                        // temp.source = $.trim(arr[0]); //来源
                        temp.source = sourceType[data.data.recordList[i].sourceType];
                        temp.id = data.data.recordList[i].id; //快讯ID
                        // temp.time = getTimeChar(data.data.recordList[i].createdAt);  //创建时间
                        temp.good = data.data.recordList[i].upCounts;  //利好
                        temp.bad = data.data.recordList[i].downCounts; //利空

                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';

                        temp.userImg = data.data.recordList[i].imgUrl ? data.data.recordList[i].coinList[0] : 'image/header.png'; //用户头像
                        temp.blocks = [];
                        //币种列表
                        var s = 0; //如果change不存在不记录
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j].change){
                                temp.blocks[s] = {};
                                temp.blocks[s].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[s].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[s].change = data.data.recordList[i].coinList[j].change ? setChange(data.data.recordList[i].coinList[j].change ) : "";
                                temp.blocks[s].name = data.data.recordList[i].coinList[j].symbol +  temp.blocks[s].change;
                                temp.blocks[s].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                s++;
                            }
                        }
                        //高亮显示
                        var keysList = obj.keys ?  obj.keys.split(" ") : [obj.keyword.toUpperCase(),obj.keyword];
                        for(var z=0; z<keysList.length; z++){
                            if(keysList[z] != ""){
                                temp.title = setHighLight(temp.title, keysList[z]);
                                temp.content = setHighLight(temp.content, keysList[z]);
                            }
                        }

                        //首先判断日期是今天还是其他日期，将相同日期的快讯放置一个数组中
                        var  dateType = getTimeType(data.data.recordList[i].createdAt);
                        temp.time = dateType.time;  //创建时间
                        if(dateType.type == 'today'){
                            if(!obj.element.quickBlock.today){
                                Vue.set(obj.element.quickBlock,'today',[]);
                            }
                            Vue.set(obj.element.quickBlock.today,obj.element.quickBlock.today.length,temp);
                        }else{
                            if(!obj.element.quickBlock[dateType.type]){
                                Vue.set(obj.element.quickBlock,dateType.type,[]);
                            }
                            Vue.set(obj.element.quickBlock[dateType.type],obj.element.quickBlock[dateType.type].length,temp);
                        }
                        temp= {};
                    }
                    $('.loadData').addClass('hidden');
                    $('.noData').addClass('hidden');
                }else{
                    sw = true;
                    $('.noData').removeClass('hidden');
                    $('.loadData').addClass('hidden');
                    obj.element.totalNum = 0;
                    console.log('没有查询到相关内容！');
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }

    }).catch(function(error){
        console.log(error);
    });
}

//3.5	查询涨跌幅榜
function getSummaryChange(obj){
    // 查询涨跌幅榜
    // url=ajaxUrl+'coins/change?timeType=1h&valueType=0';
    var url = ajaxUrl+'summary/change';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        timeType: obj.timeType, //	时间类型	是	String :	1h 1小时   1d 1天    7d 7天    30d 30天
        valueType: obj.valueType, //	涨跌类型	是	1	Number	0 涨 1 跌
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.proBlock = [];
                var temp = {};
                for(var i=0; i< data.data.length; i++){
                    //{id:1,name:'BTC',usd:'48891.33',num:'+12.34%'},
                    temp.id = data.data[i].id;
                    temp.name = data.data[i].symbol;
                    temp.usd = data.data[i].price ? '$ '+ (data.data[i].price).toFixed(4) : '-';
                    if(data.data[i].change){
                        if(data.data[i].change >= 0){
                            temp.num = setChange(data.data[i].change);

                            temp.isUp = true;
                        }else{
                            temp.num = setChange(data.data[i].change);

                            temp.isUp = false;
                        }
                    }else{
                        temp.num =  "-";

                        temp.isUp = false;
                    }


                    Vue.set(obj.element.proBlock,obj.element.proBlock.length,temp);
                    temp= {};
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.6	查询资金流向榜
function getSummaryFlow(obj){
    // url=ajaxUrl+'coins/flow?timeType=1h&directionType=0';
    var url = ajaxUrl+'summary/flow';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        timeType: obj.timeType, //	时间类型	是	1	String	30m 30分钟    1h 1小时    1d 1天    7d 7天
        directionType: obj.directionType, //	流向类型	是	1	Number	0 流入 1 流出
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var temp = {};
                for(var i=0; i< data.data.length; i++){
                    temp.id = data.data[i].id;
                    temp.name = data.data[i].symbol;
                    temp.usd = data.data[i].flowAmt ? setBitNum(data.data[i].flowAmt,2): "-";
                    temp.usdOld = data.data[i].flowAmt ? data.data[i].flowAmt: "";
                    if(data.data[i].change){
                        if(data.data[i].change >= 0){
                            temp.num = setChange(data.data[i].change);

                            temp.isUp = true;
                        }else{
                            temp.num = setChange(data.data[i].change);

                            temp.isUp = false;
                        }
                    }else{
                        temp.num =  "-";

                        temp.isUp = false;
                    }
                    Vue.set(obj.element.flowBlock,obj.element.flowBlock.length,temp);
                    temp= {};
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.7	查询交易所公告列表
function getBourList(obj){
    var url=ajaxUrl+'markets/notices';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        pageSize: obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
};
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var temp = {};
                for(var i=0; i< data.data.recordList.length; i++){
                    // {id:1,title:'比特币海外版',profile:'gate.io用户福利-立即充值分享千万GSE大奖空投'},
                    temp.id = data.data.recordList[i].id;
                    temp.from = data.data.recordList[i].from;
                    temp.title = data.data.recordList[i].title;
                    temp.time = getTimeChar(data.data.recordList[i].publishTime);
                    Vue.set(obj.element.noticeBlock,obj.element.noticeBlock.length,temp);
                    temp= {};
                }
                $('.loadData').addClass('hidden');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

// 3.8	查询交易所公告详情
function getBourNotice(obj){
    var url=ajaxUrl+'markets/notices/'+obj.noticeId;
    var params ={
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        noticeId: obj.noticeId, //	公告id	是	30	String
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.id	 = data.data.id ; //公告id	String	是
                obj.element.title = data.data.title ; //	标题	String	是
                if(data.data.zhName && data.data.zhName != ""){
                    obj.element.source = data.data.zhName ; //	交易所中文名称	String	否	可为空，为空的话，展示from字段
                }else{
                    obj.element.source = data.data.from ; //	公告发布交易所	String	是	公告发布交易所英文名
                }
                obj.element.time = getTimeChar(data.data.publishTime) ; //	发布时间	Number	是	时间戳
                obj.element.url = data.data.originUrl ; //	原文链接	String	否
                obj.element.content = data.data.content ; //	公告内容	String	是

                break;
            case 20001:
                timeOut();
                break;
            default:

        }//end 查询交易所公告
    }).catch(function(error){
        console.log(error);
    });
}

//3.9	查询文章列表
function getArticlesList(obj){
    var url=ajaxUrl+'articles';
    var params ={
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        pageSize: obj.pageSize , //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum , //	第几页	否	9	Number	默认1
        keyword: obj.keyword, //	关键字	否	100	String	不为空则表示为按照关键字或者按照币种查询
        infoType: obj.infoType , //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $('.noData').addClass('hidden');
                $('.loadData').removeClass('hidden');
                if(data.data.recordList.length > 0 ) {
                    var temp = {};
                    obj.element.totalNum = data.data.totalNum;
                    for(var i=0; i< data.data.recordList.length; i++){
                        temp.id = data.data.recordList[i].id ;
                        temp.time = getTimeChar(data.data.recordList[i].publishTime) ;
                        temp.img = data.data.recordList[i].images[0];
                        temp.title = data.data.recordList[i].title ;
                        temp.seeNum = data.data.recordList[i].readCounts ;
                        temp.userId = data.data.recordList[i].author.id ; //作者ID
                        // temp.username = data.data.recordList[i].author.authorName ; //作者名
                        if(data.data.recordList[i].author.authorName && getStrLength(data.data.recordList[i].author.authorName) >8  ){
                            temp.username = data.data.recordList[i].author.authorName.substr(0,8)+'...'; //作者名
                        }else{
                            temp.username = data.data.recordList[i].author.authorName ; //作者名
                        }
                        temp.usernameFull = data.data.recordList[i].author.authorName; //作者全名
                        temp.userImg = data.data.recordList[i].author.avatar ; //作者头像
                        temp.good = data.data.recordList[i].upCounts ;
                        temp.bad = data.data.recordList[i].downCounts ;
                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';
                        temp.content = data.data.recordList[i].abstractInfo ; //概要
                        temp.blocks = [];
                        //币种列表
                        var s =0;
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j] && data.data.recordList[i].coinList[j].change){
                                temp.blocks[s] = {};
                                temp.blocks[s].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[s].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[s].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                                temp.blocks[s].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                s++;
                            }
                        }
                        //高亮显示
                        var keysList = obj.keys ?  obj.keys.split(" ") : [obj.keyword.toUpperCase(),obj.keyword];
                        for(var z=0; z<keysList.length; z++){
                            if(keysList[z] != ""){
                                temp.title = setHighLight(temp.title, keysList[z]);
                                temp.content = setHighLight(temp.content, keysList[z]);
                            }
                        }

                        switch(parseInt(obj.infoType)){
                            case 4:
                                Vue.set(obj.element.siftBlock,obj.element.siftBlock.length,temp);
                                break;
                            case 5:
                                Vue.set(obj.element.skillBlock,obj.element.skillBlock.length,temp);
                                break;
                        }
                        // Vue.set(obj.element,obj.element.length,temp);
                        temp= {};
                    }
                    obj.element.$nextTick(function(){
                        $('.loadData').addClass('hidden');
                        $('.noData').addClass('hidden');
                        sw = true;
                    });
                }else{
                    obj.element.totalNum = 0;
                    sw = true;
                    $('.noData').removeClass('hidden');
                    $('.loadData').addClass('hidden');
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.10	查询文章详情
//obj = {token, userId,infoType , id , element }
function getArticlesText(obj){
    var url=ajaxUrl+'articles/'+obj.id;
    var params ={
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        infoType: obj.infoType,

    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        var coinIds = ""; //记录币种ID ，用于折线图
        switch(data.code){
            case 10000:
                obj.element.id= data.data.id;
                obj.element.title=data.data.title;
                obj.element.userId=data.data.author.id;
                obj.element.username=data.data.author.authorName;
                // if(data.data.author.authorName && getStrLength(data.data.author.authorName) > 2 ){
                //     obj.element.username=data.data.author.authorName.substr(0,6);
                // }else{
                //     obj.element.username=data.data.author.authorName;
                // }
                obj.element.userImg=data.data.author.avatar;
                obj.element.seeNum=data.data.readCounts;
                obj.element.time=getTimeChar(data.data.publishTime);
                obj.element.source="";
                obj.element.content=data.data.content;
                obj.element.url="";
                obj.element.good = data.data.upCounts;
                obj.element.bad = data.data.downCounts;
                obj.element.isFollow = data.data.isFollow == '1'? true :false;
                obj.element.followId = data.data.followId ?  data.data.followId: "";
                obj.element.followMsg = data.data.isFollow == '1'? '已关注': '关注';
                //币种列表
                obj.element.blacks = [];
                var s=0;
                for(var i=0; i<data.data.coinList.length; i++){
                    if(data.data.coinList[i].change){
                        obj.element.blocks[s] = {};
                        obj.element.blocks[s].id =  data.data.coinList[i].id ;
                        coinIds += data.data.coinList[i].id+',';
                        obj.element.blocks[s].symbol = data.data.coinList[i].symbol;
                        obj.element.blocks[s].imgUrl = data.data.coinList[i].imgUrl;
                        obj.element.blocks[s].Cny = data.data.coinList[i].price? '¥ '+ setBitNum(data.data.coinList[i].price * rate,2) : '-';
                        if(data.data.coinList[s].change >=0){
                            obj.element.blocks[s].change = setChange(data.data.coinList[i].change);
                            obj.element.blocks[s].isDown = false;
                        }else{
                            obj.element.blocks[s].change = setChange(data.data.coinList[i].change);
                            obj.element.blocks[s].isDown = true;
                        }
                        obj.element.blocks[s].maxCny = data.data.coinList[i].high1d ?'¥ '+  setBitNum(data.data.coinList[i].high1d * rate,2) : '-' ;
                        obj.element.blocks[s].minCny = data.data.coinList[i].low1d ? '¥ '+ setBitNum(data.data.coinList[i].low1d * rate,2) : '-' ;
                        obj.element.blocks[s].num = data.data.coinList[i].volumeEx ? setBitNum(data.data.coinList[i].volumeEx ,2) : '-' ;
                        s++;
                    }

                }
                $('.loadData').addClass('hidden');
                getCoinsHistoryList({coinIds: coinIds,element: obj.element});  //各个币种走势图
                break;
            case 20001:
                timeOut();
                break;
            default:

        }

    }).catch(function(error){
        console.log(error);
    });
}


//3.11	查询动态列表信息
//obj = {token, userId, url ,infoType , pageSize, pageNum, keyword, element }
function getDynamicList(obj){
    var url=ajaxUrl+'dynamic';
    var params ={
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        pageSize: obj.pageSize , //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum , //	第几页	否	9	Number	默认1
        keyword: obj.keyword, //	关键字	否	100	String	不为空则表示为按照关键字或者按照币种查询
        infoType: obj.infoType , //	资讯类型	是	2	Number	2 weibo 3 twitter
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(data.data.recordList.length > 0 ) {
                    $('.noData').addClass('hidden');
                    $('.loadData').removeClass('hidden');
                    var temp = {};
                    obj.element.totalNum = data.data.totalNum;
                    for(var i=0; i< data.data.recordList.length; i++){
                        //{id:1,time:'32分钟前',urls:[],title:'SoPay将受邀参加首届Linfinity Talk',blocks:[{id:"1",name:'BTC+1.21%',},{id:"2",name:'BTC+1.21%',},],username:'金色财经',good:'22',bad:'1',content:'2018年6月9日 13:00 – 17:00， 第一届Linfinity Talk全球路演第一站- 韩国首尔站，将在首尔江南区Jam2go中心举行。活动目的是构造区块链资源共享社区，展示并引导参会者深度讨论区块链项目及技术 。的是构是构是构造区块链资源共享社区，展示并引导参会者深度讨论区块链项目及技术 。'},
                        temp.id = data.data.recordList[i].id ;
                        temp.time = getTimeChar(data.data.recordList[i].createdAt) ;
                        temp.title = data.data.recordList[i].title ;
                        temp.userId = data.data.recordList[i].author.id ; //作者ID
                        temp.username = data.data.recordList[i].author.screenName ; //作者名
                        temp.userImg = data.data.recordList[i].author.avatarHd ; //作者头像
                        temp.good = data.data.recordList[i].upCounts ;
                        temp.bad = data.data.recordList[i].downCounts ;
                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';
                        temp.content = data.data.recordList[i].text ;  //微博
                        temp.cnContent = data.data.recordList[i].translation ;  //twitter
                        temp.enContent = data.data.recordList[i].text ; //twitter
                        temp.isTrans = data.data.recordList[i].translation ? true:false, //是否显示谷歌翻译
                        //缩略图list
                        temp.urls = [];
                        temp.largeUrls = [];
                        temp.urlsGeo = [];
                        temp.largeUrlsGeo = [];
                        for(var k=0; k<data.data.recordList[i].pics.length; k++){
                            temp.urls[k] = data.data.recordList[i].pics[k].url;
                            temp.largeUrls[k] =data.data.recordList[i].pics[k].largeUrl ? data.data.recordList[i].pics[k].largeUrl : "";

                            temp.urlsGeo[k] = getImgSize(data.data.recordList[i].pics[k].geo);
                            temp.largeUrlsGeo[k] = data.data.recordList[i].pics[k].largeGeo;
                        }
                        //币种列表
                        temp.blocks = [];
                        var s =0;
                        if(data.data.recordList[i].coinList){
                            for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                                if(data.data.recordList[i].coinList[j].change){
                                    temp.blocks[s] = {};
                                    temp.blocks[s].symbol = data.data.recordList[i].coinList[j].symbol;
                                    temp.blocks[s].id = data.data.recordList[i].coinList[j].id ;
                                    temp.blocks[s].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change );
                                    temp.blocks[s].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                    s++;
                                }
                            }
                        }

                        //高亮显示
                        var keysList = obj.keys ?  obj.keys.split(" ") : [obj.keyword.toUpperCase(),obj.keyword];
                        for(var z=0; z<keysList.length; z++){
                            if(keysList[z] != ""){
                                temp.title = setHighLight(temp.title, keysList[z]);
                                temp.content = setHighLight(temp.content, keysList[z]);
                                temp.cnContent = setHighLight(temp.cnContent, keysList[z]);
                                temp.enContent = setHighLight(temp.enContent, keysList[z]);
                            }
                        }
                        switch(parseInt(obj.infoType)){
                            case 2:
                                Vue.set(obj.element.blogBlock,obj.element.blogBlock.length,temp);
                                break;
                            case 3:
                                Vue.set(obj.element.twitterBlock,obj.element.twitterBlock.length,temp);
                                break;
                        }
                        temp= {};
                        // s=0
                    }
                    obj.element.$nextTick(function(){
                        $('.noData').addClass('hidden');
                        $('.loadData').addClass('hidden');
                        sw = true;
                    });

                }else{
                    obj.element.totalNum = 0;
                    sw = true;
                    $('.noData').removeClass('hidden');
                    $('.loadData').addClass('hidden');
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.12	利好利空状态更新
//obj = {token, userId, url ,infoType , flag, id 文章ID, element }
function updateUpDown(obj){
    // var url=ajaxUrl+obj.url+'/'+obj.id;
    var url=ajaxUrl+'/zan/'+obj.id;
    // var url='http://25.0.90.120:8080/v1/zan/'+obj.id;
    var data = Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        infoType: obj.infoType, //1 快讯  2 微博   3 twitter   4 精选咨询  5 技术分析
        flag: obj.flag,   //
        id: obj.id,
    });
    axios(url, {
        method: 'POST',
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
        withCredentials: true,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.good = data.data.upCounts;
                obj.element.bad = data.data.downCounts;

                //动画显示
                if(data.data.direction == 'up'){
                    $(obj.currEvent).find('.flag').text('+1').animate({'opacity':1,top:-20,'font-size':'18px'},500).delay(500).animate({'opacity':0,top:-15,'font-size':'14px'},1000);
                }else{
                    $(obj.currEvent).find('.flag').text('-1').animate({'opacity':1,top:-20,'font-size':'18px'},500).delay(500).animate({'opacity':0,top:-15,'font-size':'14px'},1000);
                }
                break;
            case 20001:
                timeOut();
                break;
            default:
        }
        isUpdate = true;
    }).catch(function(error){
        console.log(error);
        isUpdate = true;
    });
}

//3.13  更新阅读数
//obj = {token, userId, url ,articleType , id 文章ID, element }
function updateSeeNum(obj){
    var url=ajaxUrl+obj.url;
    var data=Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        articleType: obj.articleType, //4 精选咨询  5 技术分析
        id: obj.id,
    });
    axios(url, {
        method: 'POST',
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
        withCredentials: true,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.seeNum = data.data.counts;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}


//3.14	查询热门文章列表
function getHotArticles(obj){
    var url=ajaxUrl+'articles/hot/list';
    var params={
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        infoType:obj.infoType,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                // {id:1,content:"为调查市场操作行为 美国商品期货交易委员会要求比特币交易所提供交易数据"},
                var temp = {};
                obj.element.hotBlock = [];
                for(var i=0; i< data.data.length; i++){
                    // {id:1,content:"为调查市场操作行为 美国商品期货交易委员会要求比特币交易所提供交易数据"},
                    temp.index = i+1;
                    temp.id = data.data[i].id ;
                    temp.time = data.data[i].publishTime ;
                    if(getStrLength(data.data[i].title) > 34 ){
                        temp.title = data.data[i].title.substr(0,34)+'...' ;
                    }else{
                        temp.title = data.data[i].title ;
                    }

                    temp.abstractInfo = data.data[i].abstractInfo; //概要
                    temp.userId = data.data[i].author.id ; //作者ID
                    temp.username = data.data[i].author.authorName ; //作者名
                    temp.userImg = data.data[i].author.avatar ; //作者头像
                    temp.good = data.data[i].upCounts ;
                    temp.bad = data.data[i].downCounts ;
                    temp.goodImg = 'image/lihao.png';
                    temp.badImg = 'image/likong.png';
                    obj.element.seeNum=data.data.readCounts;

                    //缩略图list
                    temp.urls = [];
                    for(var k=0; k<data.data[i].images.length; k++){
                        temp.urls[k] = data.data[i].images[k].url;
                    }
                    //币种列表
                    for(var j=0; j<data.data[i].tags.length; j++){
                    }
                    Vue.set(obj.element.hotBlock,obj.element.hotBlock.length,temp);
                    temp= {};
                }
                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.15	查询币种列表
function getCoins(obj){
    var url=ajaxUrl+'coins';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        conceptId: obj.conceptId,
        sortType: obj.sortType,
        sortWord: obj.sortWord,
        pageSize:obj.pageSize,
        pageNum:obj.pageNum,
        keyword:obj.keyword,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(data.data.totalNum > 0){
                    obj.element[obj.tabType].totalNum =  Math.ceil(data.data.totalNum/obj.pageSize);  //总页数
                    obj.element[obj.tabType].list= [];
                    var coinIds = ""; //记录所有币种ID ，用于获取折线图
                    var temp = {};
                    var followList = $.cookie('followList')? $.cookie('followList').split(',') : [];
                    for(var i=0; i< data.data.recordList.length; i++){
                        temp.id = data.data.recordList[i].id ; //币种id
                        temp.index = obj.pageSize * (obj.pageNum - 1 ) + i +1;
                        temp.followId = data.data.recordList[i].followId? data.data.recordList[i].followId: ""; //自选ID
                        coinIds += temp.id+',';
                        temp.enName = data.data.recordList[i].symbol ;
                        temp.zhName = data.data.recordList[i].name ;
                        //用户没有登录，isFocus不存在，判断是否在COOKIE中存在
                        if(data.data.recordList[i].isFocus){
                            temp.isFavorite = (data.data.recordList[i].isFocus  == '1')? true: false;
                        }else{
                            if($.inArray(data.data.recordList[i].id+':0', followList) == -1){
                                temp.isFavorite = false;
                            }else{
                                temp.isFavorite = true;
                            }
                        }

                        if(data.data.recordList[i].change >= 0 ){
                            temp.isUp = true;
                        }else{
                            temp.isUp = false;
                        }
                        temp.price =data.data.recordList[i].price?'$ ' +  setBitNum(data.data.recordList[i].price) : "-" ;
                        temp.fluctuate = data.data.recordList[i].change ? setChange(data.data.recordList[i].change) : "-";
                        temp.transPirce = data.data.recordList[i].volumeEx ?'$ ' + setBitNum(data.data.recordList[i].volumeEx): "-" ; //成交额
                        temp.transNum =data.data.recordList[i].volumeCoin? setBitNum(data.data.recordList[i].volumeCoin): "-" ; //成交量
                        temp.flowNum =data.data.recordList[i].availableSupply? setBitNum(data.data.recordList[i].availableSupply):"-";  //流通数量
                        temp.marketNum =data.data.recordList[i].marketCap ?'$ ' +  setBitNum(data.data.recordList[i].marketCap) : "-" ;  //市值
                        temp.followId = data.data.recordList[i].focusId;
                        Vue.set(obj.element[obj.tabType].list,obj.element[obj.tabType].list.length,temp);
                        temp= {};
                    }
                    sw = true;
                    getCoinsHistoryList({coinIds: coinIds,element: obj.element});  //各个币种走势图


                    $('#market tfoot').removeClass('hidden');
                    $('#market .no-data').addClass('hidden');

                    $('.loadData').addClass('hidden');
                    $('.noData').addClass('hidden');
                    //页码显示
                    obj.element.setCurrPage(obj.tabType);
                }else{
                    obj.element[obj.tabType].totalNum =  0;  //总页数
                    obj.element[obj.tabType].list = [];
                    $('#market .no-data').removeClass('hidden');
                    $('#market tfoot').addClass('hidden');

                    $('.loadData').addClass('hidden');
                    $('.noData').removeClass('hidden');
                }

                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.16	查询列表币价历史
function getCoinsHistoryList(obj){
    var url=ajaxUrl+'coins/price/history';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinIds: obj.coinIds,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var dataList = [];
                var dateList = [];
                var min = 0;
                var max = 0;
                var coinIds = obj.coinIds.split(',');
                var isEmpty = 0;
                //画每个币种的折线图
                for(var i=0; i<data.data.length; i++){
                    for(var j=0; j<data.data[i].length; j++){
                        isEmpty++;
                        if(j== 0){
                            max = min = data.data[i][j].price;
                        }else{
                            if(data.data[i][j].price > max){
                                max = data.data[i][j].price;
                            }else if(data.data[i][j].price < min){
                                min = data.data[i][j].price;
                            }
                        }
                        dataList.push(data.data[i][j].price);
                        dateList.push(data.data[i][j].timestamps);
                    }
                    if(isEmpty == 0){
                        dateList = ['10-1','10-2','10-3','10-4','10-5','10-6'];
                        dataList = [-1.1,-3, 4, 1, 2, -2.2, 1, 1.6, 3.4,-3];
                        min = -3;
                        max = 5;
                    }
                    if(max <= 0 ){
                        max = 1;
                    }
                    obj.element.drawFlow(coinIds[i], dataList,dateList,min,max);
                    dataList = [];
                    dateList = [];

                    isEmpty =0;
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.17	查询币价历史
function getCoinHistory(obj){
    var url=ajaxUrl+'coins/'+obj.coinId+'/price/history';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId:obj.coinId,
        periodType: obj.periodType,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var dateArr = []; //时间戳
                var priceArr = []; //价格
                var volumeArr = []; //交易量
                var priceMin = 0;
                var priceMax = 0;
                var volMin = 0;
                var volMax = 0;
                var tempBox = {};
                var temp = {};
                var arr = [];
                //画每个币种的折线图
                for(var i=0; i<data.data.length; i++){
                    dateArr.push(obj.element.getDateStr(data.data[i].timestamps));
                    priceArr.push(data.data[i].price); //
                    volumeArr.push(data.data[i].volume); //
                    if(i == 0 ){
                        // priceMin = priceMax = Math.ceil(data.data[i].price);
                        priceMin = priceMax =data.data[i].price;
                        volMin = volMax = data.data[i].volume;
                    }else{
                        if(data.data[i].price > priceMax ){
                            // priceMax = Math.ceil(data.data[i].price);
                            priceMax = data.data[i].price;
                        }else if(data.data[i].price < priceMin ){
                            // priceMin = Math.floor(data.data[i].price);
                            priceMin = data.data[i].price;
                        }

                        if(data.data[i].volume > volMax ){
                            volMax = data.data[i].volume;
                        }else if(data.data[i].volume < volMin ){
                            volMin = data.data[i].volume;
                        }
                    }

                    //记录新闻点
                    tempBox.price =data.data[i].price ?  toThousands(data.data[i].price ,2): "-";  //价格
                    tempBox.volume  = data.data[i].volume ? toThousands(data.data[i].volume ,2): "-";  //成交额
                    tempBox.historyDate = data.data[i].timestamps ? getDivDate(data.data[i].timestamps): "-" ; //时间点
                    tempBox.newsList = [];
                    if(data.data[i].hasLive == '1'){
                        for(var j=0; j< data.data[i].liveList.length; j++){
                            arr = data.data[i].liveList[j].content.split('】');
                            if(arr.length >1){
                                temp.content = $.trim(arr[1]); //快讯内容	String	是
                                arr = arr[0].split('【');
                                arr = arr[1].split('|');
                                if(arr.length <2){
                                    arr = arr[0].split('丨');
                                }
                                temp.title = $.trim(arr[1]); //标题
                            }else{
                                temp.title = temp.content = $.trim(arr[0]); //快讯内容	String	是
                            }

                            if(getStrLength(temp.title) > 36){
                                temp.titleBack = temp.title.substr(0,36)+'...';
                            }else{
                                temp.titleBack = temp.title;
                            }

                            temp.source = sourceType[data.data[i].liveList[j].sourceType];

                            temp.id	=  data.data[i].liveList[j].id; //快讯id	String	是
                            temp.sourceType	=  sourceType[data.data[i].liveList[j].sourceType]; //快讯来源	String	是
                            temp.time=  data.data[i].liveList[j].createdAt; //	发布时间	Number	是	时间戳
                            temp.upCounts=  data.data[i].liveList[j].upCounts; //	利好个数	Number	是
                            temp.downCounts=  data.data[i].liveList[j].downCounts; //	利空个数	Number	是
                            temp.link=  data.data[i].liveList[j].link; //	原文链接	String	否	原文链接，可为空
                            tempBox.newsList.push(temp);
                            temp= {};
                        }
                    }
                    Vue.set(obj.element.newsList,obj.element.newsList.length,tempBox);
                    tempBox = {};
                }
                if(parseFloat(priceMax) <= 0){
                    priceMax  = 1;
                }

                if(priceMax - priceMin >= 10){
                    priceMax = Math.round(priceMax);
                    priceMin = Math.round(priceMin);
                }else{
                    priceMax = setBitNum(priceMax,4);
                    priceMin = setBitNum(priceMin,4);
                }
                obj.element.drawFlow(dateArr,priceArr,volumeArr,priceMin,priceMax,volMin,volMax);
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.18	查询币种详细信息
function getCoinProfile(obj){
    var url=ajaxUrl+'coins/'+obj.coinId;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId:obj.coinId,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        var followList = $.cookie('followList')? $.cookie('followList').split(',') : [];
        switch(data.code){
            case 10000:
                obj.myInfo.id = data.data.id; //币种ID
                obj.myInfo.symbol=data.data.symbol; //币种简称
                obj.myInfo.level= data.data.level;  //排名
                obj.myInfo.imgUrl= data.data.imgUrl; //币种图标
                obj.myInfo.symbolName= data.data.symbolName ? data.data.symbolName : ""; //全称
                obj.myInfo.zhName=data.data.zhName?  data.data.zhName : ""; //中文名
                obj.myInfo.price= data.data.price ? '$ '+ setBitNum(data.data.price) : "-"; //美元价格
                obj.myInfo.zhPrice= data.data.price ? '¥ '+ setBitNum(data.data.price * rate) : '-'; //人民币
                obj.myInfo.change= data.data.change1d ?  setChange(data.data.change1d) : '-'; //涨幅
                obj.myInfo.isUp = data.data.change1d && data.data.change1d >=0 ?  true : false;
                obj.myInfo.keys = data.data.keys; //搜索信息
                var now = new Date();
                var oldDate = new Date(data.data.timestamps);
                obj.myInfo.changeDate = (now.getTime()- data.data.timestamps < 24*60*60*1000) ? '(24H)' :(oldDate.getFullYear()+addZero(oldDate.getMonth()+1)+addZero(oldDate.getDate())) ;
                obj.myInfo.marketCap=data.data.marketCap ? '$ '+   setBitNum(data.data.marketCap) : '-'; //市值
                obj.myInfo.zhMarketCap=data.data.marketCap ? '¥ '+  setBitNum(data.data.marketCap * rate) : '-'; //市值 人民币
                //用户没有登录，isFocus不存在，判断是否在COOKIE中存在
                if(data.data.isFocus){
                    obj.myInfo.isFavorite = data.data.isFocus && data.data.isFocus == "1" ? true : false ;
                }else{
                    if($.inArray(obj.myInfo.id+':0', followList) == -1){
                        obj.myInfo.isFavorite = false;
                    }else{
                        obj.myInfo.isFavorite = true;
                    }
                }
                obj.myInfo.focusMsg= obj.myInfo.isFavorite ? '已自选': '加自选'; //信息
                obj.myInfo.followId = data.data.focusId;//自选ID

                obj.guessing.volumeEx= data.data.volumeEx ?  '$ '+ setBitNum(data.data.volumeEx) : '-'; //成交额
                obj.guessing.zhVolumeEx=data.data.volumeEx? '¥ '+ setBitNum(data.data.volumeEx * rate): '-'; //交易量人民币
                obj.guessing.availableSupply=data.data.availableSupply ? setBitNum(data.data.availableSupply)+data.data.symbol: '-'; //流通数量
                obj.guessing.supply=data.data.volumeCoin ? setBitNum(data.data.volumeCoin)+data.data.symbol : '-'; //发行总量
                obj.guessing.netflow1d= data.data.netflow1d ? setBitNum(data.data.netflow1d)+data.data.symbol : '-'; //主力净流入
                obj.guessing.inflow1d=data.data.inflow1d ? setBitNum(data.data.inflow1d)+data.data.symbol : '-'; //主力流入
                obj.guessing.outflow1d=data.data.outflow1d ? setBitNum(data.data.outflow1d)+data.data.symbol: '-'; //主力流出
                obj.guessing.marketCapRate=data.data.marketCapRate? setChange(data.data.marketCapRate) : 0; //市值占比
                obj.guessing.liuRate= (data.data.availableSupply && data.data.supply) ? (data.data.availableSupply / data.data.supply *100).toFixed(2)+'%' : 0; //流通率 =流通数量/发行总量
                obj.guessing.huanRate= (data.data.volumeEx && data.data.marketCap) ? (data.data.volumeEx /data.data.marketCap *100).toFixed(2)+'%' : 0 ; //换手率 =成交额/市值

                obj.guessing.symbol = data.data.symbol; //竞猜货币名称


                obj.baseInfo.symbolName= data.data.symbolName ; //全称
                obj.baseInfo.symbol= data.data.symbol; //英文
                obj.baseInfo.publicTime= getFullDate(data.data.publicTime); //发行时间
                obj.baseInfo.exNum= data.data.exNum; //上架交易所
                obj.baseInfo.explorers= data.data.explorers ?JSON.parse(data.data.explorers): []; //区块浏览地址 [“”, “”]
                obj.baseInfo.message= data.data.message ?JSON.parse(data.data.message): [];//社区论坛 [“”, “”]
                obj.baseInfo.whitepaper= data.data.whitepaper; //白皮书
                obj.baseInfo.github= data.data.github; //开源
                obj.baseInfo.websites = data.data.websites ? JSON.parse(data.data.websites): []; //官网 [“”, “”]
                obj.baseInfo.concept= data.data.concept ? JSON.parse(data.data.concept): []; //相关概念
                obj.baseInfo.zhDescriptions= data.data.descriptions ? JSON.parse(data.data.descriptions).zh[0]: "暂无" ; //概要中文 {“zh”: “”, “en”: “”}
                obj.baseInfo.enDescriptions= data.data.descriptions ? JSON.parse(data.data.descriptions).en[0]: "暂无";  //概要英文


                //获取当前货币的快讯
                obj.quickInfo.keys = data.data.keys;
                var data = {
                    pageSize:obj.quickInfo.pageSize,
                    pageNum:obj.quickInfo.currPage,
                    keyword: obj.quickInfo.keyword,
                    infoType:1,
                    element: obj.quickInfo,
                    keys: data.data.keys,
                };
                getQuikeList(data);
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
function getCoinProfileWarn(obj){
    var url=ajaxUrl+'coins/'+obj.coinId;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId:obj.coinId,
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.id = data.data.id;
                obj.element.symbol=data.data.symbol;
                obj.element.imgUrl= data.data.imgUrl; //币种图标
                obj.element.usd= data.data.price ? setBitNum(data.data.price) : "-"; //美元价格
                obj.element.cny= data.data.price ?  setBitNum(data.data.price * rate) : '-'; //人民币
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.19	查询交易所价格列表
function getTickersList(obj){
    var url=ajaxUrl+'tickers';
    var args = getUrlParams();
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        sortType:obj.sortType, //	排序类型	否	1	Number	0 升序 1 降序
        sortWord:obj.sortWord, //	排序字段	否	20	String	price/change/supply/volume/marketcap
        pageSize:obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
        coinId: obj.coinId, //币种ID
    };
    axios(url, {
        method: 'GET',
        params: params,
        withCredentials: true,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(data.data.totalNum >0){
                    obj.element[obj.tabType].totalNum =  Math.ceil(data.data.totalNum/obj.pageSize);  //总页数
                    obj.element[obj.tabType].list= [];
                    // var coinIds = []; //记录所有币种ID ，用于获取折线图
                    var followList = $.cookie('followList')? $.cookie('followList').split(',') : [];
                    var temp = {};
                    for(var i=0; i< data.data.recordList.length; i++){
                        temp.id = data.data.recordList[i].id ; //交易对ID
                        temp.index = obj.pageSize * (obj.pageNum - 1 ) + i+1;
                        temp.bourse = data.data.recordList[i].marketDisplayName ? data.data.recordList[i].marketDisplayName :  data.data.recordList[i].marketName; //交易所名称

                        //用户没有登录，isFocus不存在，判断是否在COOKIE中存在
                        if(data.data.recordList[i].isFocus){
                            temp.isFavorite = (data.data.recordList[i].isFocus  == '1')? true: false;
                        }else{

                            if($.inArray(data.data.recordList[i].id+':1', followList) == -1){
                                temp.isFavorite = false;
                            }else{
                                temp.isFavorite = true;
                            }
                        }

                        temp.followId= data.data.recordList[i].focusId ? data.data.recordList[i].focusId :"";  //自选ID
                        temp.name = data.data.recordList[i].symbolPair; //币种名称
                        temp.change = setChange(data.data.recordList[i].change); //涨跌幅
                        if(data.data.recordList[i].change >=0 ){
                            temp.isUp = true;
                        }else{
                            temp.isUp = false;
                        }
                        temp.pingtai = data.data.recordList[i].last ?  setBitNum(data.data.recordList[i].last,4) : "-"; //平台价
                        temp.newPrice = data.data.recordList[i].price? '$ '+ setBitNum(data.data.recordList[i].price,4) : "-" ; //最新价格
                        temp.maxPrice = data.data.recordList[i].high? '$ '+ setBitNum(data.data.recordList[i].high) : "-" ; //最高价格
                        temp.minPrice = data.data.recordList[i].low ? '$ '+ setBitNum(data.data.recordList[i].low) : "-"; //最低价格
                        temp.usdVolume = data.data.recordList[i].usdVolume? '$ '+ setBitNum(data.data.recordList[i].usdVolume) : "-" ; //成交额
                        temp.vol = data.data.recordList[i].vol? setBitNum(data.data.recordList[i].vol) : "-" ; //成交量
                        temp.percentage = data.data.recordList[i].percentage? setBitNum(data.data.recordList[i].percentage * 100) +'%' : "-" ; //成交量占比
                        temp.marketTime = getTickersDate(data.data.recordList[i].timestamps) ; //更新时间

                        Vue.set(obj.element[obj.tabType].list,obj.element[obj.tabType].list.length,temp);
                        temp= {};
                    }
                    sw = true;
                    obj.element.setCurrPage(obj.tabType);
                }else{
                    $('#bourse-group tfoot').addClass('hidden');
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
        getCoinsHistoryList({coinIds: "odadsfa,adodfasldfk,"});  //各个币种走势图
    });
}
//3.20	查询币种币价
function getPriceCoin(obj){
    var url=ajaxUrl+'price/coin';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        conceptId: obj.conceptId,//	概念ID	否	32	String	传入这一个概念详细信息
        coinIds: obj.coinIds,//		币种id	否	2000	string	可传入多个，逗号隔开，最多60个
        timestamps: obj.timestamps,//		时间戳	是	20	Number	根据传入时间戳进行查询，查询传入时间之后有变化的数据
};
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                break;
            case 20001:
                break;
                timeOut();
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}


//3.21  查询作者文章列表
function getAuthorAiticlesList(obj){
    //authors/{sourceId}/articles
    var url=ajaxUrl+'authors/'+obj.sourceId+'/articles';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        infoType:obj.infoType, //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
        sourceId:obj.sourceId, //	三方平台作者Id	是	30	String
        pageSize:obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.authorInfo.userId = data.data.author.id; //作者ID
                obj.authorInfo.totalNum = data.data.totalNum; //总记录数
                obj.authorInfo.isFollow= data.data.isFollow; //是否已关注
                obj.authorInfo.followMsg =  data.data.isFollow? '已关注': '关注';
                obj.authorInfo.followId = data.data.followId ? data.data.followId : ""; //关注ID
                obj.authorInfo.username= data.data.author.authorName; //作者信息
                obj.authorInfo.userImg= data.data.author.avatar ? data.data.author.avatar: "image/header.png"; //头像
                obj.authorInfo.articleCount= data.data.articleCount; //文章数
                obj.authorInfo.focusCount=data.data.focusCount ? data.data.focusCount : 0; //粉丝数
                var temp = {};
                obj.element.totalNum = data.data.totalNum;
                // obj.element = [];
                for(var i=0; i< data.data.recordList.length; i++){
                    temp.id = data.data.recordList[i].id ;
                    temp.time = getTimeChar(data.data.recordList[i].publishTime) ;
                    temp.img = data.data.recordList[i].images[0];
                    temp.title = data.data.recordList[i].title ;
                    temp.seeNum = data.data.recordList[i].readCounts ;
                    temp.userId = data.data.recordList[i].author.id ; //作者ID
                    temp.username = data.data.recordList[i].author.authorName ; //作者名
                    temp.userImg = data.data.recordList[i].author.avatar ; //作者头像
                    temp.good = data.data.recordList[i].upCounts ;
                    temp.bad = data.data.recordList[i].downCounts ;
                    temp.goodImg = 'image/lihao.png';
                    temp.badImg = 'image/likong.png';
                    temp.content = data.data.recordList[i].abstractInfo ; //概要
                    //币种列表
                    temp.blocks = [];
                    var index = 0;
                    for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                        if(data.data.recordList[i].coinList[j].change){
                            temp.blocks[index]={};
                            temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                            temp.blocks[index].id = data.data.recordList[i].coinList[j].id ;
                            temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                            temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                            index++
                        }
                    }
                    switch(parseInt(obj.infoType)){
                        case 4:
                            Vue.set(obj.element.siftBlock,obj.element.siftBlock.length,temp);
                            break;
                        case 5:
                            Vue.set(obj.element.skillBlock,obj.element.skillBlock.length,temp);
                            break;
                    }
                    index = 0;
                    temp= {};
                }
                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.22 查询关注文章列表
function getFollowAiticlesList(obj){
    var url=ajaxUrl+'authors/follow/articles';
    // console.log(obj.element2);
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        infoType:obj.infoType, //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
        pageSize:obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element2.followList  = [];
                // obj.element.followList =  [];
                obj.element2.totalNumList[params.infoType] = obj.element.totalNum =  data.data.totalNum; //总记录数

                if(data.data.totalNum > 0){
                    $('.noData').addClass('hidden');
                    var temp = {};
                    for(var i=0; i< data.data.recordList.length; i++){
                        temp.id = data.data.recordList[i].id ; //文章ID
                        temp.time = getTimeChar(data.data.recordList[i].publishTime) ; //发布时间
                        temp.img = data.data.recordList[i].images[0];  //图片
                        temp.title = data.data.recordList[i].title ;  //标题
                        temp.seeNum = data.data.recordList[i].readCounts ; //阅读数
                        temp.userId = data.data.recordList[i].author.id ; //作者ID
                        if(getStrLength(data.data.recordList[i].author.authorName) >= 8){
                            temp.username= data.data.recordList[i].author.authorName.substr(0,8)+'...'; //作者信息
                        }else{
                            temp.username= data.data.recordList[i].author.authorName; //作者信息
                        }
                        // temp.username = data.data.recordList[i].author.authorName ; //作者名
                        temp.userImg = data.data.recordList[i].author.avatar ; //作者头像
                        temp.good = data.data.recordList[i].upCounts ;  //利好数
                        temp.bad = data.data.recordList[i].downCounts ;  //利空
                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';
                        temp.content = data.data.recordList[i].abstractInfo ; //概要
                        //币种列表
                        temp.blocks = [];
                        var index = 0;
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j].change){
                                temp.blocks[index] = {};
                                temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[index].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                                temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                index++;
                            }
                        }
                        switch(parseInt(obj.infoType)){
                            case 4:
                                Vue.set(obj.element.siftBlock,obj.element.siftBlock.length,temp);
                                break;
                            case 5:
                                Vue.set(obj.element.skillBlock,obj.element.skillBlock.length,temp);
                                break;
                        }
                        index=0;
                        temp= {};
                    }
                }else{
                    $('.noData').removeClass('hidden');
                }


                //设置关注人物头像
                var man ={};
                if(data.data.focusList.length > 0){
                    $('.msg-list').removeClass('hidden');
                    $('.noUserData').addClass('hidden');
                    for( i=0; i< data.data.focusList.length; i++){
                        if(getStrLength(data.data.focusList[i].authorName) > 8){
                            man.username= data.data.focusList[i].authorName.substr(0,8)+'...'; //作者信息
                        }else{
                            man.username= data.data.focusList[i].authorName; //作者信息
                        }
                        man.fullUsername = data.data.focusList[i].authorName;  //	来源名称	String	是	三方平台作者名称
                        man.id = data.data.focusList[i].id; //	来源ID	String	是	三方平台作者Id
                        man.userImg = data.data.focusList[i].avatar ? data.data.focusList[i].avatar : 'image/header.png'; //	来源头像图片	String	否	三方平台作者头像
                        Vue.set(obj.element2.followList,obj.element2.followList.length,man);
                        man= {};
                    }
                }else{
                    $('.msg-list').addClass('hidden');
                    $('.noUserData').removeClass('hidden');
                }

                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                timeOut();
                obj.element2.followList = [];
                break;
            default:
                obj.element2.followList = [];

        }
    }).catch(function(error){
        console.log(error);
    });
}
//查询关注动态文章列表接口
function getFollowDynamicList(obj){
    var url=ajaxUrl+'authors/follow/dynamic';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        infoType:obj.infoType, //	资讯类型	是	2	Number	2 微博 3 twitter
        pageSize:obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element2.followList  =  [];
                obj.element2.totalNumList[params.infoType] = obj.element.totalNum  = data.data.totalNum; //总记录数
                if(data.data.totalNum > 0){
                    $('.noData').addClass('hidden');
                    var temp = {};
                    //获取资料
                    for(var i=0; i< data.data.recordList.length; i++){
                        temp.id = data.data.recordList[i].id ;
                        temp.time = getTimeChar(data.data.recordList[i].createdAt) ;
                        temp.title = data.data.recordList[i].title ;
                        temp.userId = data.data.recordList[i].author.id ; //作者ID
                        if(getStrLength(data.data.recordList[i].author.screenName) >= 8){
                            temp.username= data.data.recordList[i].author.screenName.substr(0,8)+'...'; //作者信息
                        }else{
                            temp.username= data.data.recordList[i].author.screenName; //作者信息
                        }
                        // temp.username = data.data.recordList[i].author.screenName ; //作者名
                        temp.userImg = data.data.recordList[i].author.avatarHd ; //作者头像
                        temp.good = data.data.recordList[i].upCounts ;
                        temp.bad = data.data.recordList[i].downCounts ;
                        temp.goodImg = 'image/lihao.png';
                        temp.badImg = 'image/likong.png';
                        temp.content = data.data.recordList[i].text ;  //微博
                        temp.cnContent = data.data.recordList[i].text ;  //twitter
                        temp.enContent = data.data.recordList[i].translation ; //twitter
                        //缩略图list
                        temp.urls = [];
                        temp.largeUrls = [];
                        temp.urlsGeo = [];
                        temp.largeUrlsGeo = [];
                        for(var u=0; u<data.data.recordList[i].pics.length; u++){
                            temp.urls[u] = data.data.recordList[i].pics[u].url;
                            temp.largeUrls[u] = data.data.recordList[i].pics[u].largeUrl;

                            temp.urlsGeo[u] = getImgSize(data.data.recordList[i].pics[u].geo);
                            temp.largeUrlsGeo[u] = data.data.recordList[i].pics[u].largeGeo;
                        }
                        //币种列表
                        temp.blocks = [];
                        var index = 0;
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j] && data.data.recordList[i].coinList[j].change){
                                temp.blocks[index] = {};
                                temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[index].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                                temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                index++;
                            }

                        }

                        switch(parseInt(obj.infoType)){
                            case 2:
                                Vue.set(obj.element.blogBlock,obj.element.blogBlock.length,temp);
                                break;
                            case 3:
                                Vue.set(obj.element.twitterBlock,obj.element.twitterBlock.length,temp);
                                break;
                        }

                        index = 0;
                        temp= {};
                    }
                }else{
                    $('.noData').removeClass('hidden');
                }

                //设置关注人物头像
                var man ={};

                if(data.data.followList.length > 0){
                    $('.msg-list').removeClass('hidden');
                    $('.noUserData').addClass('hidden');
                    for(var k=0; k< data.data.followList.length; k++){
                        if(getStrLength(data.data.followList[k].screenName) > 8){
                            man.username= data.data.followList[k].screenName.substr(0,8)+'...'; //作者信息
                        }else{
                            man.username= data.data.followList[k].screenName; //作者信息
                        }
                        man.fullUsername = data.data.followList[k].screenName;  //	来源名称	String	是	三方平台作者名称
                        man.id = data.data.followList[k].id; //	来源ID	String	是	三方平台作者Id
                        man.userImg = data.data.followList[k].avatarHd; //	来源头像图片	String	否	三方平台作者头像

                        Vue.set(obj.element2.followList,obj.element2.followList.length,man);
                        temp= {};
                    }
                }else{
                    $('.msg-list').addClass('hidden');
                    $('.noUserData').removeClass('hidden');
                }


                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                obj.element2.followList = [];
                timeOut();
                break;
            default:
                obj.element2.followList = [];
        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.24	查询热门搜索信息
function getHotWord(obj){
    var url=ajaxUrl+'hot/word';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                break;
            case 20001:
                break;
            default:

        }

        if(data.code == 10000){
            var temp = {};
            obj.element  = [];
            for(var i=0; i<data.data.length; i++){
                temp.name = data.data[i];
                Vue.set(obj.element,obj.element.length,temp);
            }
        }//end 查询热门搜索信息
    }).catch(function(error){
        console.log(error);
    });
}

//3.25	查询资讯更新条数
function getInfoUpdate(obj){
    var url=ajaxUrl+'info/updates';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        infoType:obj.infoType, //	资讯类型	是	2	Number	1 快讯 2 weibo 3 twitter 4 精选资讯 5 技术分析
        timestamps:obj.timestamp, //	时间戳	是	20	Number	查询时间戳之后更新的条数
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.updateNum = data.data.num; //更新条数
                // Vue.set(obj.element,obj.element.length,temp);
                if(data.data.num >0){
                    $('#news-information .update-num').removeClass('hidden');
                }
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.26	查询时间段内上线币种列表
function getCoinNewArea(obj){
    var url=ajaxUrl+'coins/new/'+obj.startDate+'/'+obj.endDate;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        startDate: obj.startDate, //	起始日期	是	8	String	yyyymmdd日期格式
        endDate:obj.endDate, //	截止日期	是	8	String	yyyymmdd日期格式，时间跨度不超过1个月
        };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var list = {};
                var name = "";
                for(var i=0; i<data.data.length; i++){
                    name = data.data[i].date.substr(0,4)+'-'+parseInt(data.data[i].date.substr(4,2))+ '-'+ parseInt(data.data[i].date.substr(6));
                    list[name] = data.data[i].symbol+'---newCurrency.html';
                }
                sw = true;
                addCalenderMark(list,obj.element);

                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        //日历
        var myCalender = new SimpleCalendar('#newBlock');
        addCalenderMark({},myCalender);
    });
}

//3.27	查询某一天上线币种列表
function getCoinNewDay(obj){
    var url=ajaxUrl+'coins/new/'+obj.date;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        date: obj.date,//	日期	是	8	String	yyyymmdd日期格式

    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $('.have-data').removeClass('hidden');
                $('.no-data').addClass('hidden');
                var temp = {};
                obj.element.list = [];
                for(var i=0; i<data.data.length; i++){
                    temp.id	 = data.data[i].id; //币种id	String	是
                    temp.symbolName= data.data[i].symbolName; //	币种全称	String	是
                    temp.name= data.data[i].symbol; //	币种标识	String	是
                    temp.price=data.data[i].price? setBitNum(data.data[i].price):""; //	币价	Number	是	单位为美元
                    temp.flowNum= setChange(data.data[i].change); //	24小时涨跌幅	Number	是
                    temp.isUp = (data.data[i].change) >= 0 ? true: false;
                    temp.circuNum=data.data[i].availableSupply? setBitNum(data.data[i].availableSupply):""; //	流通数量	Number	否
                    temp.transNum= data.data[i].volumeCoin? setBitNum(data.data[i].volumeCoin):""; //	成交量	Number	否
                    temp.transPrice= data.data[i].volumeEx? '$ '+ setBitNum(data.data[i].volumeEx):""; //	成交额	Number	否
                    temp.imgUrl= data.data[i].imgUrl; //	图片地址	String	是
                    temp.marketNum= data.data[i].marketCap? '$ '+ setBitNum(data.data[i].marketCap): ""; //	市值	Number	否
                    temp.bourse= data.data[i].marketName; //	交易所名称	String	是
                    temp.createDate= getFullDate(data.data[i].onlineTime); //	上线时间	Number	是	时间戳
                    temp.isFavorite= data.data[i].isFocus? true:false ; //	是否自选	Number	是	0 否 1 是

                    Vue.set(obj.element.list,obj.element.list.length,temp);
                    temp ={};
                }
                sw = true;
                break;
            case 20001:
                $('.have-data').addClass('hidden');
                $('.no-data').removeClass('hidden');
                timeOut();
                break;
            default:
                $('.have-data').addClass('hidden');
                $('.no-data').removeClass('hidden');
        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.28	查询自选列表
function getCoinFocus(obj){
    var url=ajaxUrl+'coins/follow';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        sortType: obj.sortType, //	排序类型	否	1	String	0 升序 1 降序
        sortWord: obj.sortWord, //	排序字段	否	20	String	传入对应字段名即可
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                break;
            case 20001:
                timeOut();
                break;
            default:

        }

        if(data.code == 10000){
            obj.element[obj.tabType].list = []; //清空list
            var temp = {};
            for(var i=0; i<data.data.length; i++){
                temp.id = data.data[i].coinId;
                temp.index = i +1;
                temp.enName = data.data[i].symbol;
                temp.zhName = data.data[i].coinName ? data.data[i].coinName : "";
                temp.bourse = data.data[i].marketName? data.data[i].marketName : '-';
                temp.isFavorite = true;
                if(parseFloat(data.data[i].change) >= 0){
                    temp.isUp = true;
                }else{
                    temp.isUp = false;
                }
                temp.price =data.data[i].price? setBitNum(data.data[i].price):"-"; //平台价
                temp.newPrice =data.data[i].pairPrice ?  setBitNum(data.data[i].pairPrice): "-"; //最新价格
                temp.fluctuate = setChange(data.data[i].change); //涨幅
                temp.transNum =data.data[i].volumeEx? '$ '+setBitNum(data.data[i].volumeEx): "-"; //成交额
                temp.maxPrice = data.data[i].high ? setBitNum(data.data[i].high): "-"; //最高
                temp.minPrice = data.data[i].low ?  setBitNum(data.data[i].low) : "-";
                temp.followId = data.data[i].focusId;

                Vue.set(obj.element[obj.tabType].list,obj.element[obj.tabType].list.length,temp);
                temp = {};
            }
            sw = true;
            //页码显示
            // obj.element.setCurrPage(obj.tabType);
        }//end 查询热门搜索信息
    }).catch(function(error){
        console.log(error);
    });
}
//3.29	查询汇率
function getRate(){
    var url=ajaxUrl+'exchange_rate/usd';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                rate = data.data.CNY;
                break;
            case 20001:
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.30	获取注册短信验证码
function getMsgRegistry(obj){
    var url=ajaxUrl+'msg/registry';
    var data = Qs.stringify({
        mobile: obj.mobile, //	手机号	是	11	String
        picCode: obj.picCode,//图形验证码
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch (parseInt(data.code)) {
            case 10000:
                alert('短信验证码已发送，请注意查收！');
                break;
            case 10015:
                alert('图形验证码错误！');
                break;
        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.31	注册
function getRegistry(obj){
    var url=ajaxUrl+'users';
    var data =  Qs.stringify({
        mobile: obj.mobile, //	手机号	是	11	String
        password: obj.password , //	密码	是	30	String
        smsCode: obj.smsCode, //	注册短信验证码	是	6	String
        refererMobile:$.cookie('refererMobile'), //	推荐人手机号	否	11	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $.cookie('loginNo',data.data.loginNo);//	用户名	String	30	是
                $.cookie('status',data.data.status); //	状态	String	2	是
                $.cookie('registerDat',data.data.registerDat); //	注册时间	String	8	是
                $.cookie('token',data.data.token); //	Token码	String	32	是	登陆后必填
                $.cookie('userId',data.data.userId);//	用户Id	String	20	是	登陆后必填
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });

}

//3.32	账户密码登陆
function getLogin(obj){
    var url=ajaxUrl+'login/pwd';
    var data = Qs.stringify({
        mobile: obj.mobile, //	手机号	是	11	String
        password: obj.password , //	密码	是	30	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $.cookie('loginNo',data.data.loginNo);//	用户名	String	30	是
                $.cookie('token',data.data.tokenId); //	TokenId	String	32	是	登陆后必填
                $.cookie('userId',data.data.userId);//	用户Id	String	20	是	登陆后必填

                var url = document.referrer.split('/');
                var urlArr = ['register.html','resetPassword.html','login.html'];
                if($.inArray(url[url.length-1],urlArr) >= 0){
                    location.href = 'index.html';
                }else{
                    self.location = document.referrer;
                }
                break;
            default:
                $('.username').prev().attr({'src':'image/loginName2.png'});
                $('.username').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text('');
                // $('.username').parent().find('.error-line').removeClass('hidden');

                $('.password').prev().attr({'src':'image/loginPass2.png'});
                $('.password').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text(data.message);
                $('.password').parent().find('.error-line').removeClass('hidden');
                break;
        }
    }).catch(function(error){
        $('.username').prev().attr({'src':'image/loginName2.png'});
        $('.username').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text('');
        // $('.username').parent().find('.error-line').removeClass('hidden');

        $('.password').prev().attr({'src':'image/loginPass2.png'});
        $('.password').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text('系统调试中，请稍等');
        $('.password').parent().find('.error-line').removeClass('hidden');
    });
}

//3.33	获取登陆短信验证码
function getMsgLoginPass(obj){
    var url=ajaxUrl+'msg/login';
    var data =  Qs.stringify({
        mobile: obj.mobile, //	手机号	是	11	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                alert('短信验证码已发送，请注意查收！');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.34	短信验证码登陆
function getLoginMsg(obj){
    var url=ajaxUrl+'login/msg/'+obj.mobile;
    var data =  Qs.stringify({
        mobile: obj.mobile, //	手机号	是	11	String
        msgCode: obj.msgCode , //	msgCode	短信验证码	是	30	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $.cookie('loginNo',data.data.loginNo);//	用户名	String	30	是
                $.cookie('token',data.data.tokenId); //	TokenId	String	32	是	登陆后必填
                $.cookie('userId',data.data.userId);//	用户Id	String	20	是	登陆后必填
                break;
            case 100012:
                $('#phone-login .error-line').eq(1).removeClass('hidden');
                console.log(JSON.stringify(data.message));
                $('#phone-login .error-msg').eq(1).text(data.message);
                break;
            case 100013:
                $('#phone-login .error-line').eq(1).removeClass('hidden');
                console.log(JSON.stringify(data.message));
                $('#phone-login .error-msg').eq(1).text(data.message);
                break;
        }//end
    }).catch(function(error){
        $('.phone').prev().attr({'src':'image/loginPhone2.png'});
        $('.phone').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text('');
        // $('.phone').parent().find('.error-line').removeClass('hidden');

        $('.code').prev().attr({'src':'image/loginPhone2.png'});
        $('.code').css({'border':'1px solid rgba(253,120,137,1)'}).parent().find('.error-msg').text('手机或验证码有误');
        $('.code').parent().find('.error-line').removeClass('hidden');
    });
}

//3.35	添加关注
function addAuthorsFollow(obj){
    var url=ajaxUrl+'authors/follow';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        sourceId: obj.sourceId, //	文章作者编号	是	30	String
        infoType: obj.infoType, //	资讯类型	是	2	Number	2 weibo 3 twitter 4 精选资讯 5 技术分析
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data,
        // params:params,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.isFollow = true;
                obj.element.followMsg = '已关注';
                obj.element.followId = data.data.id;
                obj.element.focusCount = data.data.followCount;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.38	取消关注
function removeAuthorsFollow(obj){
    var url=ajaxUrl+'authors/follow/'+obj.followId;
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        followId: obj.followId, //	关注ID	是	2	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data ,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.isFollow = false;
                obj.element.followMsg = '关注';
                obj.element.followId = "";
                obj.element.focusCount = data.data.followCount;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.37	添加自选
function addSelfChange(obj){
    var url=ajaxUrl+'coins/follow';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId: obj.coinId, //	币种ID
        focusType: obj.focusType , //	自选类型 0 币种 1 交易对
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(obj.element.list){
                    obj.element.list[obj.index].isFavorite = !obj.element.list[obj.index].isFavorite;
                    obj.element.list[obj.index].followId = data.data.id;
                }else{
                    obj.element.isFavorite = !obj.element.isFavorite;
                    obj.element.followId = data.data.id;
                    obj.element.focusMsg = "已添加";
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.38	取消自选
function removeSelfChange(obj){
    var url=ajaxUrl+'coins/follow/'+obj.followId;
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        followId: obj.followId, //	自选ID	是	2	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data ,
        // params:params,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(obj.element.list){
                    obj.element.list[obj.index].isFavorite = !obj.element.list[obj.index].isFavorite;
                    obj.element.list[obj.index].followId = "";
                }else{
                    obj.element.isFavorite = !obj.element.isFavorite;
                    obj.element.followId ="";
                    obj.element.focusMsg = "加自选";
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.39	提醒列表查询
function getRemindingsList(obj){
    var url=ajaxUrl+'remindings';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        // remindingType: obj.remindingType, //	提醒类型	否	1	Number	为空查询所有，0查询币种提醒，1 查询资产提醒
        // coinId: obj.coinId? obj.coinId : "", // 	币种	否	30	String   remindingType为0时，必填
        pageSize: obj.pageSize, //	每页条数	否	3	Number	默认10
        pageNum:obj.pageNum, //	第几页	否	3	Number	默认第一页
    };
    if(obj.remindingType && obj.remindingType == '1'){
        params.remindingType = obj.remindingType;
    }else if(obj.remindingType == '0'){
        params.remindingType = obj.remindingType;
        params.coinId = obj.coinId;
    }
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                if(data.data.totalNum > 0 ){
                    obj.element.totalNum = data.data.totalNum;
                    var temp = {};
                    // obj.element.list = [];
                    for(var i=0; i<data.data.recordList.length; i++){
                        temp.id	= data.data.recordList[i].id; //提醒编号	String	是
                        temp.coinId = data.data.recordList[i].coinId; //货币ID
                        temp.remindingType= data.data.recordList[i].remindingType; //	预警类型	Number	是	0 币种 1 资产
                        temp.single= data.data.recordList[i].remindingFlag; //	预警标志	Number	是	0 上涨金额 1 下跌金额
                        temp.price= toThousands(data.data.recordList[i].remindingAmt); //	预警额度	String	是
                        temp.priceType= data.data.recordList[i].currency; //	单位	String	是	币种单位，0 人民币 1 美元
                        temp.name = temp.symbol = data.data.recordList[i].symbol;
                        //以下备用
                        // temp.userId	= data.data.recordList[i].userId; //用户编号	String	是
                        // temp.coinId	= data.data.recordList[i].coinId; //币种	String	否
                        // temp.symbol	= data.data.recordList[i].symbol; //币种简写	String	否
                        // temp.status	= data.data.recordList[i].status; //状态	String	是
                        // temp.createTime	= data.data.recordList[i].createTime; //创建时间	String	是

                        Vue.set(obj.element.list,obj.element.list.length,temp);
                        temp = {};
                    }
                }else{
                    $('#info-list .no-warn-data').removeClass('hidden');
                }

                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.40	添加提醒
function addRemindings(obj){
    var url=ajaxUrl+'remindings';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId: obj.coinId ? obj.coinId : "", //	币种	否	30	String
        remindingType: obj.remindingType, //	预警类型	是	1	Number	0 币种 1 资产
        remindingFlag: obj.remindingFlag,//	预警标志	是	1	Number	0 金额 1 上涨比例 2 下跌比例
        remindingAmt: obj.remindingAmt,	//预警额度	是	18,6	Number
        currency: obj.currency, //	单位	String	是	币种单位，0 人民币 1 美元
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                //刷新list
                obj.element.list = [];
                var listParams = {
                    remindingType: obj.remindingType, //	提醒类型	否	1	Number	为空查询所有，0查询币种提醒，1 查询资产提醒
                    coinId: obj.coinId ? obj.coinId : "", // 	币种	否	30	String   remindingType为0时，必填
                    pageSize: 10, //	每页条数	否	3	Number	默认10
                    pageNum: 1, //	第几页	否	3	Number	默认第一页
                    element: obj.element,
                };
                getRemindingsList(listParams);

                getAsset({element: obj.myInfo,element2:obj.my});  //查询我的资产信息

                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.41	取消提醒
function removeRemindings(obj){
    var url=ajaxUrl+'remindings/'+obj.remindingId;
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        remindingId: obj.remindingId, //	提醒编号	是	20	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data ,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                //刷新list
                obj.element.list = [];
                var listParams = {
                    remindingType: data.remindingType, //	提醒类型	否	1	Number	为空查询所有，0查询币种提醒，1 查询资产提醒
                    coinId: obj.coinId, // 	币种	否	30	String   remindingType为0时，必填
                    pageSize: 10, //	每页条数	否	3	Number	默认10
                    pageNum: 1, //	第几页	否	3	Number	默认第一页
                    element: obj.element,
                };
                getRemindingsList(listParams);  //只刷新列表页
                //obj.type存在说明是提醒列表页的删除，无需刷新我的资产信息
                if(!obj.type){
                    getAsset({element: obj.myInfo,element2:obj.my});  //查询我的资产信息
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.42	查看积分余额
function getPoints(obj){
    var url=ajaxUrl+'points';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.totalNum = data.data.amount; //余额	Number	18.2	是
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.43	添加竞猜
function addGuesses(obj){
    var url=ajaxUrl+'guesses';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId: obj.coinId, //	币种	否	30	String
        amount: obj.amount, //	竞猜积分数量	是	18.2	Number
        guessFlag: obj.guessFlag, //	涨跌标志	是	2	String	0 看涨 1 看跌
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                getPoints(obj); //查看积分余额
                $('#currency-info .info-right').addClass('hidden');
                $('#currency-info .my-jc-result').removeClass('hidden');
                //竞猜结果
                var params = {
                    coinId: obj.coinId, //	币种	否	30	String
                    element: obj.element,
                };
                getGuessResult(params);
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.44	查询单个币种竞猜结果
function getGuessResult(obj){
    var url=ajaxUrl+'guesses/'+obj.coinId;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId: obj.coinId, //	币种	否	30	String
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.upRate = setBitNum(data.data.upRate *100)+'%'; //看涨比例	Number	18, 2	是
                obj.element.downRate = setBitNum(data.data.downRate *100)+'%'; //看跌比例	Number	18.2	是
                break;
            case 20001:
                timeOut();
                break;
            default:

        }

    }).catch(function(error){
        console.log(error);
    });
}

//3.45	记录交易记录  （记一笔）
function addTransRecords(obj){
    var url=ajaxUrl+'transRecords';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        transPlace: obj.transPlace , //	交易场所	是	30	String
        transTime: obj.transTime,//	交易时间	是	20	Number
        transCode: obj.transCode, //	交易类型	是	2	String
        outCoinId: obj.outCoinId,//	支出币种ID	是	30	String	CNY为人民币，其他为币种ID
        outSymbol: obj.outSymbol, //支出币种简写
        outCoinAmt: obj.outCoinAmt,//	支出币种数量	是	18, 6	Number
        inCoinId: obj.inCoinId,//	获得币种ID	是	30	String	CNY为人民币，其他为币种ID
        inSymbol: obj.inSymbol, // 获得币种简写
        inCoinAmt: obj.inCoinAmt,//	获得币种数量	是	18, 6	Number
        transUnit: obj.transUnit,//交易对格式
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                // $('#recordModal').find('.no-record-data').addClass('hidden');

                $('#recordModal').modal('hide');
                getAsset({element: obj.myInfo,element2:obj.my});  //查询我的资产信息
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.46	交易记录查询  个人主页-交易记录
function getTransRecords(obj){
    var url=ajaxUrl+'transRecords';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        pageSize: obj.pageSize, //	每页条数	否	3	Number	默认10
        pageNum:obj.pageNum, //	第几页	否	3	Number	默认第一页
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.totalNum = data.data.totalNum;
                var temp = {};
                if(data.data.totalNum > 0){
                    for(var i=0; i<data.data.recordList.length; i++){
                        //{id:1,time:'2018-06-14 16:23:21',addr:'场外交易',type:'卖出',fname:"USDT",fnum:"159,123.13",tname:"BTC",tnum:"9.8812",selected:false},
                        temp.id	= data.data.recordList[i].id; //交易记录编号	Number	30	是
                        temp.userId	= data.data.recordList[i].userId; //用户编号	String	是
                        temp.addr= obj.element.addrType[data.data.recordList[i].transPlace]; //	交易场所	是	30	String
                        temp.transTime= data.data.recordList[i].transTime; //	交易时间	是	20	Number
                        temp.type= obj.element.transType[data.data.recordList[i].transCode]; //	交易类型	是	2	String
                        temp.outCoinId= data.data.recordList[i].outCoinId; //	支出币种ID	是	30	String	CNY为人民币，其他为币种ID
                        temp.fname= data.data.recordList[i].outCoinSymbol; //	支出币种简写	是	20	String	CNY为人民币，其他为币种symbol
                        temp.fnum= data.data.recordList[i].outAmt; //	支出币种数量	是	18, 6	Number
                        temp.inCoinId= data.data.recordList[i].inCoinId; //	获得币种ID	是	30	String	CNY为人民币，其他为币种ID
                        temp.tname= data.data.recordList[i].inCoinSymbol; //	获得币种简写	是	20	String	CNY为人民币，其他为币种symbol
                        temp.tnum= data.data.recordList[i].inCount; //	获得币种数量	是	18, 6	Number
                        temp.time= getFullDate(data.data.recordList[i].createTime); //	创建时间	是	20	Number	时间戳

                        Vue.set(obj.element.items,obj.element.items.length,temp);
                        temp = {};
                    }
                }else{
                    $('#recordModal').find('.no-record-data').removeClass('hidden');
                }
                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.47	交易记录删除 (交易记录页面)
function removeTransRecords(obj){
    // var url=ajaxUrl+'transRecords/'+obj.transRecordId;
    var url=ajaxUrl+'transRecords/deletion';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        transRecordIds: obj.transRecordIds, //	交易记录编号	是	30	String
    },{indeices:false});
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data: data ,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.48	我的资产查询  个人中心-我的资产
function getAsset(obj){
    var url=ajaxUrl+'asset';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.totalNum = data.data.totalNum;
                obj.element.capitalUsd= obj.element.capitalUsdBack='$ '+  setBitNum(data.data.capital,2); //	投入本金	String	是	交易记录表中，场外交易 买入总和- 卖出总和
                obj.element.capitalCny= obj.element.capitalCnyBack='¥ '+ setBitNum(data.data.capital * rate,2); //	投入本金	String	是	交易记录表中，场外交易 买入总和- 卖出总和
                obj.element.totalPriceUsd= obj.element.totalPriceUsdBack=data.data.totalAsset?'$ '+ setBitNum(data.data.totalAsset,2) : 0; //	资产估值	Number	是	每个币种数量 * 单价，加和
                obj.element.totalPriceCny= obj.element.totalPriceCnyBack=data.data.totalAsset?'¥ '+  setBitNum(data.data.totalAsset * rate,2) : 0 ; //	资产估值	Number	是	每个币种数量 * 单价，加和

                obj.element.sumProfitAmtUsd= obj.element.sumProfitAmtUsdBack='$ '+  setBitNum(data.data.totalAsset - data.data.capital,2); //	累计收益	Number	是	估值-本金
                obj.element.sumProfitAmtCny= obj.element.sumProfitAmtCnyBack='¥ '+ setBitNum(data.data.totalAsset * rate - data.data.capital *rate,2); //	累计收益	Number	是	估值-本金
                //左边菜单的注册手机号和时间

                obj.element2.mobile= data.data.mobile; //	登录账号	String	是
                obj.element2.registerDate= getFullDate(data.data.registerDate); //	注册时间	Number	是
                $.cookie('mobile',data.data.mobile); //	登录账号	String	是
                $.cookie('registerDate',getFullDate(data.data.registerDate)); //	注册时间	Number	是

                var temp = {};
                var tempPie = {};
                var pieData = [];  //饼图数据
                obj.element.pieBlock = [];
                obj.element.blockList = [];
                obj.element.list = [];
                Vue.set(obj.element, 'pieList',[]);
                console.log(obj.element.pieList);
                if(data.data.acctList.length == 0){
                    obj.element.pieOption.series[0].data =[{value:100, name:'no'}];
                    obj.element.pieOption.series[0].color =['rgba(238,238,238,1)'];
                    obj.element.pieOption.series[0].itemStyle.normal.borderWidth  = 0;

                    $('.no-login-table').removeClass('hidden');
                }else{
                    $('.no-login-table').addClass('hidden');
                    var other = 0;  //如果比例小于10%，并入其他
                    var colorIndex = 0;
                    for(var i=0; i<data.data.acctList.length; i++){
                        temp.id	= data.data.acctList[i].coinId; //币种ID	String	是
                        temp.symbol	= tempPie.symbol =  data.data.acctList[i].symbol; //币名简写	String	是
                        temp.name= data.data.acctList[i].name; //	币名	String	是
                        temp.zhName	= data.data.acctList[i].zhName; //中文名	String	否
                        temp.isUp = (data.data.acctList[i].change >=0)? true:false;
                        temp.price= temp.priceBack =  data.data.acctList[i].price ? '¥ '+setBitNum(data.data.acctList[i].price * rate): '-'; //	价格	Number	否
                        temp.fluctuate	=data.data.acctList[i].changeId ? setChange(data.data.acctList[i].changeId):'-'; //24小时涨跌幅	Number	否
                        temp.num= setBitNum(data.data.acctList[i].amt); //	持有个数	Number	是
                        temp.flowNum =  temp.flowNumBack = tempPie.flowNum =tempPie.flowNumBack = data.data.acctList[i].asset ?'¥ '+ setBitNum(data.data.acctList[i].asset * rate): "-"; //资产估值	Number	是

                        temp.isWarn= data.data.acctList[i].isRemind == '1' ? true : false; //	是否设置提醒	Number	是	0 未设置 1已设置
                        //以下饼图需要需要数据
                        temp.color = tempPie.color =  obj.element.color[colorIndex]; //饼图颜色
                        // temp.rate = parseInt(data.data.acctList[i].price * data.data.acctList[i].amt / data.data.totalAsset * 100) +'%' ;  //各个币种占比，饼图用
                        temp.rate =  temp.rateBack = tempPie.rate = tempPie.rateBack =  Math.round(data.data.acctList[i].asset / data.data.totalAsset * 100) + '%' ;  //各个币种占比，饼图用
                        if(Math.round(data.data.acctList[i].asset / data.data.totalAsset * 100) < 10){
                            other += Math.round(data.data.acctList[i].asset);
                        }else{
                            colorIndex++;
                            pieData.push(Math.round(data.data.acctList[i].asset));
                            Vue.set(obj.element.pieList,obj.element.pieList.length,tempPie);
                        }
                        Vue.set(obj.element.list,obj.element.list.length,temp);
                        temp = {};
                        tempPie = {};
                    }

                    if(other != 0){
                        pieData.push(Math.round(other));
                        tempPie = {};
                        tempPie.symbol = '其他';
                        tempPie.flowNum =tempPie.flowNumBack = other ?'¥ '+ setBitNum(other * rate): "-";
                        tempPie.rate = tempPie.rateBack = Math.round(other / data.data.totalAsset * 100) + '%' ;  //各个币种占比，饼图用
                        // tempPie.flowNum = tempPie.flowNumBack = other;
                        tempPie.color =  obj.element.color[colorIndex]; //饼图颜色
                        Vue.set(obj.element.pieList,obj.element.pieList.length,tempPie);
                    }
                    sw = true;
                    obj.element.pieOption.series[0].data = pieData; //写入数据
                }
                obj.element.drawPie(); //画饼图
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.51	积分明细列表查询  个人中心- 积分明细
function getPointsList(obj){
    var url=ajaxUrl+'points/list';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        pageSize: obj.pageSize, //	每页条数	否	3	Number	默认10
        pageNum:obj.pageNum, //	第几页	否	3	Number	默认第一页
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.totalNum = data.data.totalNum;
                var temp = {};
                for(var i=0; i<data.data.recordList.length; i++){
                    temp.changeType= data.data.recordList[i].changeType ? '-': '+'; //	变更类型	Number	是	0 增加 1减少
                    temp.type= opType[data.data.recordList[i].opType]; //	获取方式	Number	是	操作类型：0 注册 1 推荐 2 登陆 3 竞猜 4 分享
                    temp.amt= temp.changeType + data.data.recordList[i].amt; //	数量	Number	是
                    temp.time	= getFullDateTime(data.data.recordList[i].createTime); //创建时间	Number	是	时间戳
                    Vue.set(obj.element.items,obj.element.items.length,temp);
                    temp = {};
                }

                sw =true;
                $('.loadData').addClass('hidden');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.52	积分汇总列表查询  个人中心- 积分明细-总览
function getPointsSum(obj){
    var url=ajaxUrl+'points/sum';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var totalInt = 0;
                for(var i=0; i<data.data.length; i++){
                    switch (parseInt(data.data[i].opType)) {
                        //0 注册 1 推荐  2 登陆 3 竞猜 4 分享
                        case 0:
                            obj.element.regNum = data.data[i].sumAmt? data.data[i].sumAmt : 0; //注册数量
                            totalInt += obj.element.regNum;
                            obj.element.regNum = addPlusMinus(obj.element.regNum);
                            break;
                        case 1:
                            obj.element.recomNum = data.data[i].sumAmt? data.data[i].sumAmt : 0; //注册数量
                            totalInt += obj.element.recomNum;
                            obj.element.recomNum = addPlusMinus(obj.element.recomNum);
                            break;
                        case 2:
                            obj.element.signIn = data.data[i].sumAmt? data.data[i].sumAmt : 0; //注册数量
                            totalInt += obj.element.signIn;
                            obj.element.signIn = addPlusMinus(obj.element.signIn);
                            break;
                        case 3:
                            obj.element.guesing = data.data[i].sumAmt? data.data[i].sumAmt : 0; //注册数量
                            totalInt += obj.element.guesing;
                            obj.element.guesing = addPlusMinus(obj.element.guesing);
                            break;
                        case 4:
                            obj.element.shareNum = data.data[i].sumAmt? data.data[i].sumAmt : 0; //注册数量
                            totalInt += obj.element.shareNum;
                            obj.element.shareNum = addPlusMinus(obj.element.shareNum);
                            break;
                    }
                }
                obj.element.total =  totalInt;
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.53	生成登陆图形验证码
function getPicLogin(obj){
    var url=ajaxUrl+'pic';
    var params = {  };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.imgUrl = 'data:image/png;base64,'+data.data.img;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.54	获取重置密码短信验证码
function getMsgPwd(obj){
    var url=ajaxUrl+'msg/pwd';
    var params = {
        mobile:obj.mobile, //	手机号	是	11	String
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                alert('短信验证码已经发送，请注意查收！');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.56	保存新密码
function saveNewPwd(obj){
    var url=ajaxUrl+'newPwd';
    var data = Qs.stringify({
        mobile:obj.mobile, //	手机号	是	11	String
        smsCode:obj.smsCode, //		短信验证码	是	6	String
        password:obj.password, //		新密码	是	30	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                alert('密码设置成功！');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.57	意见反馈信息保存
function setFeedback(obj){
    var url=ajaxUrl+'feedback';
    var data =  Qs.stringify({
        mobile:obj.mobile, //	手机号	是	11	String
        opinion:obj.opinion, //		反馈意见	是	256	String
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                // alert('提交成功！');
                $('.show-box').addClass('hidden');
                $('.hide-box').removeClass('hidden');
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.58	退出登陆
function safeQuit(){
    var url=ajaxUrl+'logout';
    var data =  Qs.stringify({
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
        headers:{
            'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8",
        },
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                $.cookie('userId',null,{expires:-1});
                $.cookie('token',null,{expires:-1});
                location.reload();
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.59	查询微博（twitter）用户动态列表信息
function getAuthorDynamicList(obj){
    var url=ajaxUrl+'authors/'+obj.sourceId+'/dynamic';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        infoType:obj.infoType, //	文章类型	是	2	Number	2 微博  3 twitter
        sourceId:obj.sourceId, //	三方平台作者Id	是	30	String
        pageSize:obj.pageSize, //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum, //	第几页	否	9	Number	默认1
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.authorInfo.userId = data.data.author.id; //作者ID
                obj.authorInfo.totalNum = data.data.totalNum; //总记录数
                obj.authorInfo.isFollow= data.data.isFollow; //是否已关注
                obj.authorInfo.followMsg =  data.data.isFollow? '已关注': '关注';
                obj.authorInfo.followId = data.data.followId; //关注ID
                obj.authorInfo.username= data.data.author.authorName; //作者信息
                obj.authorInfo.userImg= data.data.author.avatarHd; //头像
                obj.authorInfo.articleCount= data.data.articleCount; //文章数
                obj.authorInfo.focusCount=data.data.focusCount ? data.data.focusCount : 0; //粉丝数
                var temp = {};
                obj.element.totalNum = data.data.totalNum;
                for(var i=0; i< data.data.recordList.length; i++){
                    temp.id = data.data.recordList[i].id ;
                    temp.time = getTimeChar(data.data.recordList[i].createdAt) ;
                    temp.title = data.data.recordList[i].title ;
                    temp.userId = data.data.recordList[i].author.id ; //作者ID
                    temp.username = data.data.recordList[i].author.screenName ; //作者名
                    temp.userImg = data.data.recordList[i].author.avatarHd ? data.data.recordList[i].author.avatarHd : 'image/header.png'; //作者头像
                    temp.good = data.data.recordList[i].upCounts ;
                    temp.bad = data.data.recordList[i].downCounts ;
                    temp.goodImg = 'image/lihao.png';
                    temp.badImg = 'image/likong.png';
                    temp.content = data.data.recordList[i].text ;  //微博
                    temp.cnContent = data.data.recordList[i].translation ;  //twitter
                    temp.enContent = data.data.recordList[i].text ; //twitter
                    temp.isTrans = data.data.recordList[i].translation? true:false, //是否显示谷歌翻译
                    //缩略图list
                    temp.urls = [];
                    temp.largeUrls = [];
                    temp.urlsGeo = [];
                    temp.largeUrlsGeo = [];
                    for(var k=0; k<data.data.recordList[i].pics.length; k++){
                        temp.urls[k] = data.data.recordList[i].pics[k].url;
                        temp.largeUrls[k] = data.data.recordList[i].pics[k].largeUrl;

                        temp.urlsGeo[k] = getImgSize(data.data.recordList[i].pics[k].geo);
                        temp.largeUrlsGeo[k] = data.data.recordList[i].pics[k].largeGeo;
                    }
                    //币种列表
                    temp.blocks = [];
                    var index =0 ;
                    if(data.data.recordList[i].coinList){
                        for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                            if(data.data.recordList[i].coinList[j].change){
                                temp.blocks[index] = {};
                                temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                temp.blocks[index].id = data.data.recordList[i].coinList[j].id ;
                                temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                                temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                index++;
                            }
                        }
                    }
                    switch(parseInt(obj.infoType)){
                        case 2:
                            Vue.set(obj.element.blogBlock,obj.element.blogBlock.length,temp);
                            break;
                        case 3:
                            Vue.set(obj.element.twitterBlock,obj.element.twitterBlock.length,temp);
                            break;
                    }
                    index=0;
                    temp= {};
                }
                $('.loadData').addClass('hidden');
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}
//3.60	查询币种列表页风口概念列表   （货币列表上面的概念）
function getCoinSummary(obj){
    // var url=ajaxUrl+'coins/concepts/summary';
    var url=ajaxUrl+'summary/concepts/list';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.items = [];
                var temp = {};
                var index = false;
                for(var i=0; i< data.data.length; i++){
                    //{id:1,name:'世界杯',num:"3.67%",down:false},
                    temp.id	= data.data[i].id ; //概念id	String	是
                    if(obj.conceptId == data.data[i].id){
                        index = i;
                        obj.element2.name=data.data[i].name;
                        obj.element2.avgChange= setChange(Math.abs(data.data[i].avgChange),true);
                        obj.element2.coinCounts=data.data[i].coinCounts;
                        obj.element2.upCounts=data.data[i].upCounts;
                        obj.element2.downCounts=data.data[i].downCounts;
                        obj.element2.upMostCoinInfo=data.data[i].upMostCoinInfo;
                        obj.element2.downMostCoinInfo=data.data[i].downMostCoinInfo;
                        if(data.data[i].avgChange < 0){
                            obj.element2.down = true;
                        }else{
                            obj.element2.down = false;
                        }
                    }
                    temp.name= data.data[i].name ; //	概念名	Number	是
                    temp.avgChange	= setChange(Math.abs(data.data[i].avgChange),true) ; //平均涨跌幅	coinList	是
                    temp.coinCounts	= data.data[i].coinCounts ; //币种数	Number	是
                    temp.upCounts= data.data[i].upCounts ; //	上涨个数	Number	是
                    temp.downCounts	= data.data[i].downCounts ; //下跌个数	Number	是
                    temp.upMostCoinInfo= data.data[i].upMostCoinInfo ; //	涨幅最高币种信息	CoinInfo	否
                    temp.downMostCoinInfo= data.data[i].downMostCoinInfo ; //	涨幅最低币种信息	CoinInfo	否
                    temp.upMostCoinInfo.changeABS =  setBitNum(Math.abs(data.data[i].upMostCoinInfo.change),2);
                    temp.downMostCoinInfo.changeABS =  setBitNum(Math.abs(data.data[i].downMostCoinInfo.change),2);
                    if(data.data[i].avgChange < 0){
                        temp.down = true;
                    }else{
                        temp.down = false;
                    }
                    Vue.set(obj.element.items,obj.element.items.length,temp);
                    temp= {};
                }

                obj.element.$nextTick(function(){
                    obj.element.setSliderWidth();


                    //显示首页进入的风口概念
                    if(index !==  false){
                        $('#currency-nav').find('.currency-item').addClass('currency-item-active currency-item-changed');
                        $('#currency-nav').find('.currency-num').addClass('currency-num-changed');
                        $('.currency-item').eq(index).addClass('currency-item-changed').removeClass('currency-item-active');
                        $('.currency-item').eq(index).find('.currency-num').addClass('currency-num-changed');
                        var width = 0 - parseFloat($('.currency-item').eq(0).outerWidth(true)) * parseInt(index);
                        $('.item-box').css('left',width);
                        //具体风口概念的样式
                        $('#currency-header').find('li').removeClass('active');
                        $('#currency-header').find('li[value=0]').addClass('active');
                        $('.tab-pane').removeClass('active');
                        $('#market').addClass('active');
                        $('#currency-info').removeClass('hidden');
                    }

                    $('.loadData').addClass('hidden');
                    sw = true;

                });
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.61	查询币价历史中快讯列表   （币价详情中折线图 ，某点的资讯）
function getLivesCoinHistory(obj){
    var url=ajaxUrl+'lives/coin/history';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        coinId: obj.coinId, //	币种id	是	30	String
        periodType: obj.periodType, //	区间类型	是	10	String	1d/1w/1m/3m/1y/ty/all
        timestamps: obj.timestamp, //	时间戳	是		Number	时间戳
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.totalNum = data.data.totalNum;
                var temp = {};
                var cont = data.data.recordList.length > 3 ? 3 : data.data.recordList.length; //只需要最多3条
                for(var i=0; i< cont; i++){
                    temp.id	= data.data.recordList[i].id ; //概念id	String	是
                    // temp.sourceType	= data.data.recordList[i].sourceType ; //	快讯来源	String	是
                    temp.sourceType = sourceType[data.data.recordList[i].sourceType];
                    temp.createAt	= data.data.recordList[i].createAt ; //	发布时间	Number	是	时间戳
                    temp.content	= data.data.recordList[i].content ; //	快讯内容	String	是
                    temp.upCounts	= data.data.recordList[i].upCounts ; //	利好个数	Number	是
                    temp.downCounts	= data.data.recordList[i].downCounts ; //	利空个数	Number	是
                    temp.link	= data.data.recordList[i].link ; //	原文链接	String	否	原文链接，可为空

                    Vue.set(obj.element,obj.element.length,temp);
                    temp= {};
                }
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//查询搜索列表
function getSearchList(obj){
    var url=ajaxUrl+'search';
    obj.keyword =obj.keyword.toUpperCase();
    // obj.keyword =obj.keyword;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token') :"",
        userId: $.cookie('userId')?$.cookie('userId') :"",
        infoType: obj.infoType ,
        pageSize: obj.pageSize , //	每页条数	否	9	Number	默认10，最大50
        pageNum: obj.pageNum , //	第几页	否	9	Number	默认1
        keyword: obj.keyword, //	关键字	否	100	String	不为空则表示为按照关键字或者按照币种查询
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params: params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                switch( parseInt(obj.infoType)){
                    case 1:
                        if(data.data.recordList.length > 0 ){
                            $('.noData').addClass('hidden');
                            $('.loadData').removeClass('hidden');
                            var temp = {};
                            obj.element.totalNum = data.data.totalNum;
                            for(var i=0; i< data.data.recordList.length; i++){
                                var arr = data.data.recordList[i].content.split('】');
                                if(arr.length >1){
                                    temp.content = $.trim(arr[1]); //快讯内容	String	是
                                    arr = arr[0].split('【');
                                    arr = arr[1].split('|');
                                    if(arr.length <2){
                                        arr = arr[0].split('丨');
                                    }
                                    temp.title = $.trim(arr[1]); //标题
                                }else{
                                    temp.title = temp.content = $.trim(arr[0]); //快讯内容	String	是
                                }

                                temp.source = sourceType[data.data.recordList[i].sourceType];
                                temp.id = data.data.recordList[i].id; //快讯ID
                                temp.time = getTimeChar(data.data.recordList[i].createdAt);  //创建时间
                                temp.good = data.data.recordList[i].upCounts;  //利好
                                temp.bad = data.data.recordList[i].downCounts; //利空
                                temp.goodImg = 'image/lihao.png';
                                temp.badImg = 'image/likong.png';
                                temp.blocks = [];
                                //币种列表
                                var index = 0;
                                for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                                    if(data.data.recordList[i].coinList[j] && data.data.recordList[i].coinList[j].change) {
                                        temp.blocks[index] = {};
                                        temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                        temp.blocks[index].id = data.data.recordList[i].coinList[j].id;
                                        temp.blocks[index].change = data.data.recordList[i].coinList[j].change ? setChange(data.data.recordList[i].coinList[j].change) : "";
                                        temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + temp.blocks[index].change;
                                        temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >= 0 ? true : false;
                                        index++;
                                    }
                                }
                                //高亮显示
                                if(obj.keyword != ""){
                                    temp.title = setHighLight(temp.title, obj.keyword);
                                    temp.content = setHighLight(temp.content, obj.keyword);
                                }

                                //首先判断日期是今天还是其他日期，将相同日期的快讯放置一个数组中
                                var  dateType = getTimeType(data.data.recordList[i].createdAt);
                                temp.time = dateType.time;  //创建时间
                                if(dateType.type == 'today'){
                                    if(!obj.element.quickBlock.today){
                                        Vue.set(obj.element.quickBlock,'today',[]);
                                    }
                                    Vue.set(obj.element.quickBlock.today,obj.element.quickBlock.today.length,temp);
                                }else{
                                    if(!obj.element.quickBlock[dateType.type]){
                                        Vue.set(obj.element.quickBlock,dateType.type,[]);
                                    }
                                    Vue.set(obj.element.quickBlock[dateType.type],obj.element.quickBlock[dateType.type].length,temp);
                                }
                                temp= {};
                                index = 0;
                            }
                            $('.loadData').addClass('hidden');
                            $('.noData').addClass('hidden');
                            sw= true;
                        }else{
                            $('.noData').removeClass('hidden');
                            $('.loadData').addClass('hidden');
                        }
                        break;
                    case 2:
                    case 3:
                        if(data.data.recordList.length > 0 ){
                            $('.noData').addClass('hidden');
                            $('.loadData').removeClass('hidden');
                            obj.element.totalNum = data.data.totalNum;
                            var temp = {};
                            for(var i=0; i< data.data.recordList.length; i++){
                                temp.id = data.data.recordList[i].id ;
                                temp.time = getTimeChar(data.data.recordList[i].createdAt) ;
                                temp.title = data.data.recordList[i].title ;
                                temp.userId = data.data.recordList[i].author.id ; //作者ID
                                temp.username = data.data.recordList[i].author.screenName ; //作者名
                                temp.userImg = data.data.recordList[i].author.avatarHd ; //作者头像
                                temp.good = data.data.recordList[i].upCounts ;
                                temp.bad = data.data.recordList[i].downCounts ;
                                temp.goodImg = 'image/lihao.png';
                                temp.badImg = 'image/likong.png';
                                temp.content = data.data.recordList[i].text ;  //微博
                                temp.cnContent = data.data.recordList[i].translation ;  //twitter
                                temp.enContent = data.data.recordList[i].text ; //twitter
                                temp.isTrans = data.data.recordList[i].translation ? true:false, //是否显示谷歌翻译
                                //缩略图list
                                temp.urls = [];
                                temp.largeUrls = [];
                                temp.urlsGeo = [];
                                temp.largeUrlsGeo = [];
                                for(var k=0; k<data.data.recordList[i].pics.length; k++){
                                    temp.urls[k] = data.data.recordList[i].pics[k].url;
                                    temp.largeUrls[k] =data.data.recordList[i].pics[k].largeUrl ? data.data.recordList[i].pics[k].largeUrl : "";

                                    temp.urlsGeo[k] = getImgSize(data.data.recordList[i].pics[k].geo);
                                    temp.largeUrlsGeo[k] = data.data.recordList[i].pics[k].largeGeo;
                                }
                                //币种列表
                                temp.blocks = [];
                                var index = 0;
                                if(data.data.recordList[i].coinList){
                                    for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                                        if(data.data.recordList[i].coinList[j] && data.data.recordList[i].coinList[j].change) {
                                            temp.blocks[index] = {};
                                            temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                            temp.blocks[index].id = data.data.recordList[i].coinList[j].id;
                                            temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change);
                                            temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >= 0 ? true : false;
                                            index++;
                                        }
                                    }
                                }

                                //高亮显示
                                if(obj.keyword != ""){
                                    temp.title = setHighLight(temp.title, obj.keyword);
                                    temp.content = setHighLight(temp.content, obj.keyword);
                                    temp.cnContent = setHighLight(temp.cnContent, obj.keyword);
                                    temp.enContent = setHighLight(temp.enContent, obj.keyword);
                                }

                                if(obj.infoType == '2') {
                                    Vue.set(obj.element.blogBlock,obj.element.blogBlock.length,temp);
                                }else{
                                    Vue.set(obj.element.twitterBlock,obj.element.twitterBlock.length,temp);
                                }


                                temp= {};
                                index = 0;
                            }
                            $('.loadData').addClass('hidden');
                            $('.noData').addClass('hidden');
                            sw =true;
                        }else{
                            $('.noData').removeClass('hidden');
                            $('.loadData').addClass('hidden');
                        }

                        break;
                    case 4:
                    case 5:
                        if(data.data.recordList.length > 0 ){
                            obj.element.totalNum = data.data.totalNum;
                            $('.noData').addClass('hidden');
                            $('.loadData').removeClass('hidden');
                            var temp = {};
                            for(var i=0; i< data.data.recordList.length; i++){
                                temp.id = data.data.recordList[i].id ;
                                temp.time =data.data.recordList[i].publishTime? getTimeChar(data.data.recordList[i].publishTime): "" ;
                                temp.img = data.data.recordList[i].images[0];
                                temp.title = data.data.recordList[i].title ;
                                temp.seeNum = data.data.recordList[i].readCounts ;
                                temp.userId = data.data.recordList[i].author.id ; //作者ID
                                temp.username = data.data.recordList[i].author.authorName ; //作者名
                                temp.userImg = data.data.recordList[i].author.avatar ; //作者头像
                                temp.good = data.data.recordList[i].upCounts ;
                                temp.bad = data.data.recordList[i].downCounts ;
                                temp.goodImg = 'image/lihao.png';
                                temp.badImg = 'image/likong.png';
                                temp.content = data.data.recordList[i].abstractInfo ; //概要
                                temp.blocks = [];
                                //币种列表
                                var index = 0;
                                for(var j=0; j<data.data.recordList[i].coinList.length; j++){
                                    if(data.data.recordList[i].coinList[j] && data.data.recordList[i].coinList[j].change){
                                        temp.blocks[index] = {};
                                        temp.blocks[index].symbol = data.data.recordList[i].coinList[j].symbol;
                                        temp.blocks[index].id = data.data.recordList[i].coinList[j].id ;
                                        temp.blocks[index].name = data.data.recordList[i].coinList[j].symbol + setChange(data.data.recordList[i].coinList[j].change) ;
                                        temp.blocks[index].isUp = data.data.recordList[i].coinList[j].change >=0 ? true : false;
                                        index++;
                                    }
                                }
                                //高亮显示
                                if(obj.keyword != ""){
                                    temp.title = setHighLight(temp.title, obj.keyword);
                                    temp.content = setHighLight(temp.content, obj.keyword);
                                }

                                if(obj.infoType == '4') {
                                    Vue.set(obj.element.siftBlock,obj.element.siftBlock.length,temp);
                                }else{
                                    Vue.set(obj.element.skillBlock,obj.element.skillBlock.length,temp);
                                }
                                temp= {};
                                index = 0;
                            }
                            $('.loadData').addClass('hidden');
                            $('.noData').addClass('hidden');
                            sw = true;
                        }else{
                            $('.noData').removeClass('hidden');
                            $('.loadData').addClass('hidden');
                        }

                        break;
                }
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.63	币种过滤接口
function filterCoins(obj){
    var url=ajaxUrl+'filter/coin';
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        keyword	: obj.keyword,//关键字	否	100	String	关键字搜索使用
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                switch(parseInt(obj.type)){
                    case 0:
                        $('.buy-info .left').find('.get-currency').removeClass('hidden');
                        obj.element.outItems = [];
                        break;
                    case 1:
                        $('.buy-info .right').find('.get-currency').removeClass('hidden');
                        obj.element.inItems = [];
                        break;
                }
                var temp = {};
                if(data.data.length > 0){
                    for(var i=0; i< data.data.length; i++){
                        temp.id	= data.data[i].id ; //币种id	String	是
                        temp.symbol	= data.data[i].symbol ; //	币种全称	String	是
                        temp.name	= data.data[i].name ? ' ('+data.data[i].name+')' : ""; //	币种标识	String	是
                        switch(parseInt(obj.type)){
                            case 0:
                                $('#recordModal .left .no-currency-data').addClass('hidden');
                                Vue.set(obj.element.outItems,obj.element.outItems.length,temp);
                                break;
                            case 1:
                                $('#recordModal .right .no-currency-data').addClass('hidden');
                                Vue.set(obj.element.inItems,obj.element.inItems.length,temp);
                                break;
                        }
                        temp= {};
                    }
                }else{
                    switch(parseInt(obj.type)){
                        case 0:
                            $('#recordModal .left .no-currency-data').removeClass('hidden');
                            break;
                        case 1:
                            $('#recordModal .right .no-currency-data').removeClass('hidden');
                            break;
                    }
                }
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.99	查询cookie自选
function getFollowLocalCoins(obj){
    var url=ajaxUrl+'follow/local/coin';
    var data = Qs.stringify({
        coinIds	: obj.coinIds,//cookie记录的币种ID
    });
    axios(url, {
        method: 'POST',
        withCredentials: true,
        data:data,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element[obj.tabType].list = []; //清空list
                var temp = {};
                for(var i=0; i<data.data.length; i++){
                    temp.id = data.data[i].coinId;
                    temp.index = i +1;
                    temp.enName = data.data[i].symbol;
                    temp.zhName = data.data[i].coinName ? data.data[i].coinName : "";
                    temp.bourse = data.data[i].marketName? data.data[i].marketName : '-';
                    temp.isFavorite = true;
                    if(parseFloat(data.data[i].change) >= 0){
                        temp.isUp = true;
                    }else{
                        temp.isUp = false;
                    }
                    temp.price =data.data[i].price? setBitNum(data.data[i].price):"-"; //平台价
                    temp.newPrice =data.data[i].pairPrice ?  setBitNum(data.data[i].pairPrice): "-"; //最新价格
                    temp.fluctuate = setChange(data.data[i].change); //涨幅
                    temp.transNum =data.data[i].volumeEx? '$ '+setBitNum(data.data[i].volumeEx): "-"; //成交额
                    temp.maxPrice = data.data[i].high ? setBitNum(data.data[i].high): "-"; //最高
                    temp.minPrice = data.data[i].low ?  setBitNum(data.data[i].low) : "-";
                    temp.followId = data.data[i].focusId;

                    Vue.set(obj.element[obj.tabType].list,obj.element[obj.tabType].list.length,temp);
                    temp = {};
                }
                sw = true;
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}

//3.64	查询快讯详情
function getLivesText(obj){
    var url=ajaxUrl+'lives/'+obj.id;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        liveId:obj.id, //	快讯Id	是	24	String
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                var arr = data.data.content.split('】');
                if(arr.length > 1){
                    obj.element.content = $.trim(arr[1]); //内容
                    arr = arr[0].split('【');
                    arr = arr[1].split('|');
                    if(arr.length <2){
                        arr = arr[0].split('丨');
                    }
                    obj.element.title = $.trim(arr[1]); //标题
                }else{
                    obj.element.title =  obj.element.content = $.trim(arr[0]); //内容和标题
                }
                obj.element.source = sourceType[data.data.sourceType];
                obj.element.time = getTimeChar2(data.data.createdAt);  //创建时间
                obj.element.good = data.data.upCounts;  //利好
                obj.element.bad = data.data.downCounts; //利空

                obj.element.id = data.data.id; //	快讯id	String	是
                obj.element.link = data.data.link; //	原文链接	String	否	原文链接，可为空

                var temp = {};
                var coinIds = "";
                // var s = 0; //如果change不存在不记录
                for(var j=0; j<data.data.coinList.length; j++){
                    if(data.data.coinList[j].change){
                        temp.id = data.data.coinList[j].id ;
                        coinIds += temp.id+',';
                        temp.symbol = data.data.coinList[j].symbol;
                        temp.change = data.data.coinList[j].change ? setChange(data.data.coinList[j].change ) : "";
                        temp.name = data.data.coinList[j].symbol +  temp.change;
                        temp.isDown = data.data.coinList[j].change >=0 ? false : true;


                        temp.imgUrl = data.data.coinList[j].imgUrl;
                        temp.maxCny	 = data.data.coinList[j].high1d ? setBitNum(data.data.coinList[j].high1d,2): "-"; //最高币价	Number	是
                        temp.minCny =data.data.coinList[j].low1d ? setBitNum(data.data.coinList[j].low1d,2): "-"; //	最低币价	Number	是
                        temp.num= data.data.coinList[j].volumeEx ? setBitNum(data.data.coinList[j].volumeEx,2): "-"; //	交易额	Number	是
                        // s++;

                        Vue.set(obj.element.blocks,obj.element.blocks.length,temp);
                        temp= {};
                    }
                }

                getCoinsHistoryList({coinIds: coinIds,element: obj.element});  //各个币种走势图

                console.log(obj.element.blocks);

                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}


//3.65	查询动态详情信息
function getDynamicText(obj){
    var url=ajaxUrl+'dynamic/'+obj.id;
    var params = {
        tokenId: $.cookie('token')?$.cookie('token'): "",   //	Token码	否	32	String	登陆后必填
        userId:$.cookie('userId')?$.cookie('userId'): "",   //	用户Id	否	20	String	登陆后必填
        dynamicId:obj.id, //	快讯Id	是	24	String
    };
    axios(url, {
        method: 'GET',
        withCredentials: true,
        params:params,
    }).then(function(response){
        var data = response.data;
        switch(data.code){
            case 10000:
                obj.element.id = data.data.id ;
                obj.element.time = getTickersDate(data.data.createdAt) ;
                obj.element.title = data.data.title ;
                obj.element.userId = data.data.author.id ; //作者ID
                obj.element.username = data.data.author.screenName ; //作者名
                obj.element.userImg = data.data.author.avatarHd ; //作者头像
                obj.element.good = data.data.upCounts ;
                obj.element.bad = data.data.downCounts ;
                obj.element.goodImg = 'image/lihao.png';
                obj.element.badImg = 'image/likong.png';
                obj.element.content = data.data.text ;  //微博
                obj.element.cnContent = data.data.translation ;  //twitter
                obj.element.enContent = data.data.text ; //twitter
                obj.element.isTrans = data.data.translation ? true:false, //是否显示谷歌翻译
                //缩略图list
                obj.element.urls = [];
                obj.element.largeUrls = [];
                obj.element.urlsGeo = [];
                obj.element.largeUrlsGeo = [];

                // var temp = {};
                for(var k=0; k<data.data.pics.length; k++){
                    Vue.set(obj.element.urls,obj.element.urls.length,data.data.pics[k].url);
                    Vue.set(obj.element.largeUrls,obj.element.largeUrls.length,(data.data.pics[k].largeUrl ? data.data.pics[k].largeUrl : ""));
                    Vue.set(obj.element.urlsGeo,obj.element.urlsGeo.length,getImgSize(data.data.pics[k].geo));
                    Vue.set(obj.element.largeUrlsGeo,obj.element.largeUrlsGeo.length,data.data.pics[k].largeGeo);
                }
                //币种列表
                obj.element.blocks = [];

                var temp = {};
                // var s = 0; //如果change不存在不记录
                var coinIds = "";
                for(var j=0; j<data.data.coinList.length; j++){
                    if(data.data.coinList.change){
                        temp.id = data.data.coinList[j].id ;
                        coinIds += temp.id+',';
                        temp.symbol = data.data.coinList[j].symbol;
                        temp.change = data.data.coinList[j].change ? setChange(data.data.coinList[j].change ) : "";
                        temp.name = data.data.coinList[j].symbol +  temp.change;
                        temp.isDown = data.data.coinList[j].change >=0 ? false : true;
                        // s++;

                        temp.imgUrl = data.data.coinList[j].imgUrl;
                        temp.maxCny	 = data.data.coinList[j].high1d ? setBitNum(data.data.coinList[j].high1d * rate,2): "-"; //最高币价	Number	是
                        temp.minCny =data.data.coinList[j].low1d ? setBitNum(data.data.coinList[j] * rate.low1d,2): "-"; //	最低币价	Number	是
                        temp.num= data.data.coinList[j].volumeEx ? setBitNum(data.data.coinList[j] * rate.volumeEx,2): "-"; //	交易额	Number	是

                        Vue.set(obj.element.blocks,obj.element.blocks.length,temp);
                        temp= {};
                    }
                }
                getCoinsHistoryList({coinIds: coinIds,element: obj.element});  //各个币种走势图
                break;
            case 20001:
                timeOut();
                break;
            default:

        }
    }).catch(function(error){
        console.log(error);
    });
}



